HOWTO: properly call methods asynchronously???

  • Thread starter Thread starter Alex Glass
  • Start date Start date
A

Alex Glass

I have a component I'm using in my application. When I call a method
myComponent.slowMethod() my entire application hangs until slowMethod()
completes. I have tried using the .net threading model to trigger the
slowMethod inside a thread wrapper class but I still have the same behavior.
Is there anything I might be missing here?

Thanks for any help,
Alex
 
Is it a control? Controls are not thread safe. Use BeginInvoke() to call
(actually queue) the method indirectly. If you're the author of the code in
the slowMethod, you can put Application.DoEvents() throughout the
slowMethod's code to ensure that it doesn't block the UI message pump....
there might be some consequences with using Application.DoEvents depending on
what you're doing in the code- but I've never had a problem.
 
Back
Top