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 2 2006 2:48 PM
Hello, Need some help here. We have a client/server windows app that is acting strange ever since we upgraded to 2.0 framework. We use async calls for all database operations. Some folks are getting the following error "Endinvoke can only be called once from an async operation". Some users get the error, some users don't, some times the user that gets the error will at times not have a problem, very strange. Here is a sample of our code: ProcessServer pas = new ProcessServer(); AsyncCallback RemoteCallback = new AsyncCallback(this.ValidateInspectorCallback); //call to server ValidateInspectorDelegate del = new ValidateInspectorDelegate(pas.ValidateInspector); IAsyncResult ar = del.BeginInvoke( mdiform.UserValidateData, process, netid, pass, workprocessid, RemoteCallback, null); //callback method private void ValidateInspectorCallback(IAsyncResult ar) { try { ValidateInspectorDelegate del = (ValidateInspectorDelegate)((AsyncResult)ar).AsyncDelegate; Dataset xdlogds = del.EndInvoke(ar); NoParmDelegate ed = new NoParmDelegate( this.ValidateInspectorReceipt); this.Invoke(ed); ValidateInspectorReceipt(); } catch (ApcsException ae) { CallBackMessage( ae.Text, false); } catch (Exception e) { CallBackMessage( e.Message, true); } } //the validateinspectorreciept method returns us to main thread //callbackmessage function protected void CallBackMessage( string message, bool showstaff) { CallBackMessageDelegate ed = new CallBackMessageDelegate( this.ShowCallBackMessage); this.Invoke(ed, new Object[]{message, showstaff}); return; } protected void ShowCallBackMessage( string message, bool showstaff) { if (showstaff) em.ShowStaffErrorBox(message); else em.ShowErrorBox(message); return; } What is happening is that the callback function call is in a loop, it keeps getting called for about 5 0r 6 times and then proceeds normally. Don't know why the callback function is getting called again. I was thinking it had something to do with the invoke method in the callback, so I took that out and just called the function validateinspectorreciept method directly and not through delegate. This worked, but I'm thinking that is not thread safe, and the invoke method was thread safe. Does anybody have any ideas. Katie
Reply
Answers (
0
)
VB.Net and Access DB
Take picture with digital camera using C#