Hi All,

I have a strange situation, im not sure if its even possible what i have to do hence the post. I cannot think of any way this problem can be solved however, i've been wrong before so best to check with you all.

I have a function "Connect" which calls another function "MakeConnection". MakeConnection returns imeditaly and its success or failure is determined by a callback to "OnConnected" or "OnDisconnected".

This is were things start to get tricky, the Connect function needs to return true or false. If MakeConnection returns imeditaly how can i determine what the result should be before i return from the Connect function.

Code:
BOOL g_bConnected = FALSE;
BOOL g_bDisconnected = FALSE;

BOOL Connect(...)
{
  MakeConnection(...);

  // Need to "pause" for either the OnConnected or OnDisconnected
  // callback so i can get the result of MakeConnection

  return TRUE/FALSE??
}

callback void OnConnected(...)
{
  g_bConnected = TRUE;
}

callback void OnDisconnected(...)
{
  g_bDisconnected = TRUE;
}
The problem is pausing after MakeConnection means the callbacks themselves cant execute anyway, so its stuck..

I've thought about differnt threadding ideas but non of them actully solve the problem.. :S

Any ideas or is this impossible as i currently think?