David

David

  • NA
  • 5
  • 0

Make asynchronous method synchronous

Dec 6 2006 4:36 PM
Does anybody have any ideas on a way to make an asynchronous method behave in a synchronous way? I will not go in to much detail about what I am doing because it would take a long time.

Basically I have a method that I call which performs a function and, when complete, raises an event method(delegate). This is just like how the Ping object's SendAsync method works, to give one example. The problem is, I need to be able to make this function behave synchronously.

The best I have been able to come up with so far is to call the asynchronous function, and loop until some variable is changed when the delegate method is raised. That seems messy to me though.

Can anybody think of a better way? This is kind of hard for me to explain. If it is not clear, let me know and I will try a different way.