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
C#

Avatar of undefined
Last Comment
ianinspain

8/22/2022 - Mon
SOLUTION
Mike Tomlinson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
atoth

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Gururaj Badam

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
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/Programming/Programming_Languages/C_Sharp/Q_21990578.html

Splitting points for this question... Ian

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23