Writing a class library, in which function return a string value based on window message received using the window handle.
Currently, not able to wait asynchronously to receive window message. Below is pseudo code which is being used.
namespace TestIntialization
{
public class Example : Form
{
string status = "";
public string init()
{
Example ex = new Example();
ex.intialise(this.Handle); // this handle used for receiving window message
// Need to wait for wndProc handler to update string value.
return status;
}
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x2000)
{
status = "SUCESS";
}
if (m.Msg == 0x2001)
{
status = "FAILURE";
}
base.WndProc(ref m);
}
}
}
Tried option like Thread.sleep,EventWaitHandle's WaitOne function but this function block the running thread. I am receiving expected window message in WndProc handler but value are reaching message handler only after exiting init function. So not able to inform calling application about success or failure status.
No comments:
Post a Comment