How to make a "Modal Object" ?

  • Thread starter Thread starter Steph.
  • Start date Start date
S

Steph.

How can I make a "ModalObject" that will react like a ModalForm ? I mean an object that will run in it's own message loop and return a value (a string value) when closed.



Example :



private void SomeFunction()

{

ModalObject modalObject = new ModalObject();

If (modalObject.Execute = "OK")

{

//Do some code.

}

}



Thanks For any help !!



Steph.
 
Steph. schreef:
How can I make a "ModalObject" that will react like a ModalForm ? I mean an object that will run in it's own message loop and return a value (a string value) when closed.



Example :



private void SomeFunction()

{

ModalObject modalObject = new ModalObject();

If (modalObject.Execute = "OK")

{

//Do some code.

}

}



Thanks For any help !!



Steph.


Maybe this help.
I didn't test it.

private string _returnMessage;
private bool _closing=false;

public string Execute()
{
while (!_closing)
{
//do nothing
//sleep
}

return _returnMessage;
}

private void Form1_Closing(object sender, CancelEventArgs e)
{
// set message
// set _closing variable to true
_closing=true;
}

Maybe you can also use the closed event.
 
Back
Top