473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How delay firing again

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
4 1159
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: yoyo | last post by:
Is there anyway to delay a trigger from firing for a few seconds? I have an after insert trigger on table1, which selects information from table2 and table3. Obviously it cannot fire unless the...
3
by: ELO | last post by:
Hi all Every week, I need to get two files on a remote server. I have developped a C# Windows Service with two System.Threading.Timer to do this task For the first one, the delay (TimeSpan...
5
by: Steve M | last post by:
Why are my sessions lasting so long? I have them set to 20 minute timeout in config file? The Session_End event is getting called an hour or more sometimes--well after the user has stopped...
18
by: Max | last post by:
This is a follow-up on my previous thread concerning having the program wait for a certain date and time and then executing some code when it gets there. My question is; can I use the Sleep...
6
by: Woody Splawn | last post by:
Is there a way in vb.net to delay the firing of certain code till after everything else has run? That is, I have an event with some code in it that needs to run AFTER everything else has run...
14
by: Rene Grothmann | last post by:
I have managed to communicate between forms and Java applets. A button press sends the content of the text area to an applet, a second button gets some text from the applet and puts it into the...
19
by: furiousmojo | last post by:
This is a strange problem. I have a project where the contents of global.asax application_error are not firing. It is an asp.net 2.0 application using web application projects. I have another...
2
by: Umeshnath | last post by:
Hi, I have a web application that refreshes a label control every 1 sec (interval set by timer control). I am using Atlas panel for refreshing. Basically I have a method say PollMSMQ(), which...
3
by: =?Utf-8?B?Um9iZXJ0IFNsYW5leQ==?= | last post by:
I have a state transition trigger by a Delay Activity. If I include the default SQL persistence service, this state transition is fired twice. Any suggestions ?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.