Link to home
Start Free TrialLog in
Avatar of ianinspain
ianinspain

asked on

500pts: Help need to display a modal form and continue code execution

Hi there,

I am having a little issue and wonder if anyone can help with a workaround etc..

basically i have some code that tries and sends an email so i display a small form over the top (no title bar, min, max buttons etc) and it says "Trying to send, please wait..." ...

If i showDialog then all my code execution stops....,  i wondering if there was an event that is fired once on the Dialog form to say its SHOWN and then i could do my email code here and then close the form but there isn't ... Event load isn't good enough because it fires before the form is shown

Event activated seems to fire all the time when it looses focus so this is no good either...

If i use a non-modal show then all my other forms are still accepting input, of course i can say Stay On Top.... but it just doesn't behave like a modal form.

Does anyone know of a good trick or work around to acheive what i am trying to do.

I am a little stuck

Thanks in advance

Ian
SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think this may not be the optimal approach but still it will work

You can subscribe to the Parent form's Activated event and in this you can check whether your progress window is instantiated. If so, you can simple set focus to your progress window instead.

NOTE: There will be slight flickerring effect when the user click on the parent window and the focus changes to child window

private void ParentWindow_Activated(object sender, EventArgs e)
{
      if( frmProgressWindow != null )
            frmProgressWindow.Activate();
}

~Gururaj
Avatar of ianinspain
ianinspain

ASKER

Wow thanks guys... i am now playing with threads!! I got my method running and it works... but i need a callback when its finsihed ... I thought it only fair to open a new question.,... https://www.experts-exchange.com/questions/21990578/500pts-Callback-for-a-thread.html

Splitting points for this question... Ian