By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,197 Members | 1,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,197 IT Pros & Developers. It's quick & easy.

How delay firing again

P: n/a
I had it happen again today that I needed some code to run upon loading the
form but the code that I needed to have run needed to run AFTER all the rest
of Visual Studio's events had fired. Due to the fact that the Visual Studio
events continued to fire after I ran my code, it goofed things up. Isn't
there any way to fix it so that the code you want to run upon startup of a
form is insured to run only after VS has fired all it's events?

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Woody,

What event handler do you currently have your code in, and what events are
firing after that eventhandler runs?

Kerry Moorman
"Woody Splawn" wrote:
I had it happen again today that I needed some code to run upon loading the
form but the code that I needed to have run needed to run AFTER all the rest
of Visual Studio's events had fired. Due to the fact that the Visual Studio
events continued to fire after I ran my code, it goofed things up. Isn't
there any way to fix it so that the code you want to run upon startup of a
form is insured to run only after VS has fired all it's events?


Nov 21 '05 #2

P: n/a
What event is firing after your code? How does Visual Studio doesn't fire
events. If you just run the exe created Visual Studio isn't involved
anymore. I think your talking about the framework firing event, in which
case we need to know what is happening to mess you up. More info please.

Chris
"Woody Splawn" <No**********@jts.bz> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...
I had it happen again today that I needed some code to run upon loading the
form but the code that I needed to have run needed to run AFTER all the
rest
of Visual Studio's events had fired. Due to the fact that the Visual
Studio
events continued to fire after I ran my code, it goofed things up. Isn't
there any way to fix it so that the code you want to run upon startup of a
form is insured to run only after VS has fired all it's events?


Nov 21 '05 #3

P: n/a
If I understand your problem correctly, the fix is pretty simple.

Create a class level boolean variable in your form class.

Private m_IsLoading as boolean=true

Add this line as the first line inside your events that you don't want to
run while VS is initiailizing the form at startup.

Public Sub SomeEvent(s as sender, e as eventargs) handles blah.blah
If m_IsLoading = True Then Return
' rest of event code here...
End Sub

Then in your Form Load event set m_IsLoading=false.

This solved a lot of issues I had like this.

HTH,
Greg
"Woody Splawn" <No**********@jts.bz> wrote in message
news:e2**************@TK2MSFTNGP09.phx.gbl...
I had it happen again today that I needed some code to run upon loading the
form but the code that I needed to have run needed to run AFTER all the
rest
of Visual Studio's events had fired. Due to the fact that the Visual
Studio
events continued to fire after I ran my code, it goofed things up. Isn't
there any way to fix it so that the code you want to run upon startup of a
form is insured to run only after VS has fired all it's events?


Nov 21 '05 #4

P: n/a
Woody Splawn wrote...
I had it happen again today that I needed some code to run upon loading the
form but the code that I needed to have run needed to run AFTER all the rest
of Visual Studio's events had fired. Due to the fact that the Visual Studio
events continued to fire after I ran my code, it goofed things up. Isn't
there any way to fix it so that the code you want to run upon startup of a
form is insured to run only after VS has fired all it's events?


Sorry for the C# code but it is all I have:

private void OnAfterLoad()
{
// do stuff here you want done after form loads
}

private void ProgressDialog_Load(object sender, System.EventArgs e)
{
// form load code goes here
BeginInvoke(new MethodInvoker(OnAfterLoad));
label2.Text = "Finished loading form";
}
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.