Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

 

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

JvCoach23

VB.Net newbie

MS Sql Vet

Posted

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.

Nothing is as illusive as 'the last bug'.
Posted
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.

JvCoach23

VB.Net newbie

MS Sql Vet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...