Oct 22, 2013, 1:08 PM
[CLOSED] Allowed activities in task manager
What should not be done in ThreadPool.QueueUserWorkItem()?
I have several processes that perform multiple actions (Update primary table in database, send out an email, update secondary tables in database, refresh columns in a grid store and publish on the MessageBus to update other fields in detail panels.
My original design just showed a mask "Processing ..." and everything was fine. Then one day I noticed I was hanging for a while and eventually a message box was displayed alerting me that an email could not be sent out. So I decided to alter the design and add a task manager to handle the longaction and within the long action update a session variable to let the user know what step was being processed (Just like the example TaskManager -> Basic -> Poll Server) which you created because of this thread [CLOSED] DirectEvent Mask Message post #14.
An additonal thread about this was discussed in Oct 2011 - [CLOSED] ProgressBar Server Side Update with some good suggestions in post #9.
I did not try to implement Marcelo's suggestion yet about resetting the Session for the thread because I passed in all of the session variables that my process needed, but as noted in Post #15 my next issue was when trying to update grid store record elements and then commit the record.
After forgetting that I had posted about this last December I finally tracked it down to the ResourceManager.ScriptOrderNumber which uses HttpContext.Current which is null in the thread.
In my thread I performing the following:
Do you believe that Marcelo's suggestion is the best one?
Should certain actions never occur in a thread?
Any suggestions?
I have several processes that perform multiple actions (Update primary table in database, send out an email, update secondary tables in database, refresh columns in a grid store and publish on the MessageBus to update other fields in detail panels.
My original design just showed a mask "Processing ..." and everything was fine. Then one day I noticed I was hanging for a while and eventually a message box was displayed alerting me that an email could not be sent out. So I decided to alter the design and add a task manager to handle the longaction and within the long action update a session variable to let the user know what step was being processed (Just like the example TaskManager -> Basic -> Poll Server) which you created because of this thread [CLOSED] DirectEvent Mask Message post #14.
An additonal thread about this was discussed in Oct 2011 - [CLOSED] ProgressBar Server Side Update with some good suggestions in post #9.
I did not try to implement Marcelo's suggestion yet about resetting the Session for the thread because I passed in all of the session variables that my process needed, but as noted in Post #15 my next issue was when trying to update grid store record elements and then commit the record.
After forgetting that I had posted about this last December I finally tracked it down to the ResourceManager.ScriptOrderNumber which uses HttpContext.Current which is null in the thread.
In my thread I performing the following:
...
// Grab the row that is being updated (Works just fine)
var requestSelected = RequestGridPanel.GetStore().GetById(requestId);
// ** Loop through the dictionary of updates (Problem when in a thread process)
foreach (var column in columnUpdates)
requestSelected.Set(column,Key, column.Value);
requestSelected.Commit();
...
By calling requestSelected.Set eventually the Ext.Net.BaseControl.AddScript(string script) method is called executing the following line:this.ProxyScripts.Add(ResourceManager.ScriptOrderNumber, TokenUtils.ReplaceRawToken(TokenUtils.ParseTokens(script, this)));
The script parameter is "App.Requests_Store.getById(5233).set(\"ActUserNm\ ", \"BobSmith\");". It is failing with "An entry with the same key already exists." and the reason is ResourceManager.ScriptOrderNumber is always returning 0 when in the thread thus the second item in the foreach loop fails because the first item was already added.Do you believe that Marcelo's suggestion is the best one?
Should certain actions never occur in a thread?
Any suggestions?
Last edited by Daniil; Oct 22, 2013 at 5:03 PM.
Reason: [CLOSED]