TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
katie walsh
NA
2
0
Async operations with 2.0 framework
Aug 15 2006 1:57 PM
We have been running our application successfully for over a year using async calls. We recently upgraded to .net 2.0 framework on our test server and our async calls are having some issues. All DB calls are done asynchronously, here is the pattern we use: private void somefunctioncall() { try { ProssessServerCall pas = new ProcessServerCall(); AsyncCallback RemoteCallback = new AsyncCallback(this.callbackfunction); ValidateDataDelegate del = new ValidateDataDelegate(pas.ValidateData); IAsyncResult ar = del.BeginInvoke(some parameters); SetWait(); //this } catch(Exception e) { ..... } } private void callbackfunction(IAsyncResult ar) { try { ValidateDataDelegate del = (ValidateDataDelegate)((AsyncResult)ar).AsyncDelegate; dataset ds = del.EndInvoke(ar); NoParmDelegate ed = new NoParmDelegate(this.BackToUIfunction); this.Invoke(ed); } catch(Exception e) { CallBackMessage(e.message,true); } ResetWait(); //were thinking this caused the problem } //Callback message Protected void CallBackMessage(string message,bool showstaff) { CallBackMessageDelegate ed = new CallBackMessageDelegate(this.ShowCallBAckMessage); this.Invoke(ed,new object[](message,showstaff}); } } protected void ResetWait() { try { NoPartDelegate ad = new NoParmDelegate(this.ResetCursor); this.Invoke(ad); } catch(Exception ex) { } } I think maybe the ResetWait is causing the problem, what happens is that we appear to be in a loop. The callbackfunction keeps getting called again, so the endinvoke gets called again, which causes an InvalidOperationException to be thrown, cause you can't call EndInvoke more than once from asynch call. We did change the ResetWait function to: if(this.InvokeRequired) { noparmdelegate ad = new noparmdelegate(this.resetcursor); Invoke(ad); } else ResetCursor(); } This seemed to work, but then folks were still having some issues. We are stumped, any ideas anyone. Do we need the InvokeRequired on all Invoke calls in the callback function? Katie
Reply
Answers (
0
)
Threading not working within Sharepoint Portal...
dynaimally updating UI from worker thread