jvcoach23 Posted April 6, 2005 Posted April 6, 2005 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 Quote JvCoach23 VB.Net newbie MS Sql Vet
IngisKahn Posted April 6, 2005 Posted April 6, 2005 Think about it... you probably hit end try before callit even runs. :) Error handling doesn't work across threads. Quote "Who is John Galt?"
Wile Posted April 6, 2005 Posted April 6, 2005 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. Quote Nothing is as illusive as 'the last bug'.
jvcoach23 Posted April 6, 2005 Author Posted April 6, 2005 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. Quote JvCoach23 VB.Net newbie MS Sql Vet
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.