BeginInvoke

jvcoach23

Centurion
Joined
May 22, 2003
Messages
192
Location
Saybrook, IL
I'm using the BeginInoke to return a sqldatareader from a secondary thread back to the ui. it is working great.. unless the database I'm trying to connect to is offline or the server isn't availble. So I was going to wrap the BeginInvoke in a try and catch.. however

Visual Basic:
try
BeginInvoke(callit)
catch ex as exception
debug...
end try

the catch doesn't catch the exception.. what do I need to put in there so the program doesn't bomb out.. I'd like to put a nice message out to the debug.writeline for my development cycle..

thanks
shannon
 
You might try Invoke instead of BeginInvoke.
Where BeginInvoke runs asynchronous, Invoke runs synchronuos. So the Invoke method runs only after the method that was invoked, has finished. the invoked method will still be executed on the GUI thread so that won't be a problem either.

But like IngisKahn says, big chance that won't help either. Errors are something that happens along a call-stack. Different threads have completely separate call stacks so they probably dont propagate cross threads.
 
Wile said:
You might try Invoke instead of BeginInvoke.
Where BeginInvoke runs asynchronous, Invoke runs synchronuos. So the Invoke method runs only after the method that was invoked, has finished. the invoked method will still be executed on the GUI thread so that won't be a problem either.

But like IngisKahn says, big chance that won't help either. Errors are something that happens along a call-stack. Different threads have completely separate call stacks so they probably dont propagate cross threads.


thanks for the help. Yes, that makes sense now. I think I'm going to do a check when I make the call to the database. if it doesn't make a connection, i'll artifically put a row in the resultset so that the invoke always has something to chew on.

thanks again for the help.
 
Back
Top