i have created a small program with an update check feature. So that when a user clicks "check for update" a form is displayed that checks.. However, using the mybase.load event makes it check for the update before the form is displayed, meaning the user wont get feedback untill after the checking procedure is complete. How can i make the program launch this event automatically after the form has loaded?
that is what I have done, but this results in what ive already mentioned.. This also results in long loading times when you open the form as it wont display before the actions are executed..
Re: [RESOLVED] [2005] After form has loaded event?
If I understand you, you want the user to click an 'Update' button which launches a form on which the user clicks something else to actually do the update, right? If that's the case then I'd move the update from the Load event to the Click event.
Alternatively, maybe you want the 2nd form more like a splash screen, where it simply appears while the update takes place in the background. I'm not sure exactly how to do that, but I'd probably look at starting a new thread for the update while continuing with the Load procedure (which would no longer contain the update) in the current thread. When the update is done it raises an event in the displayed form. Like I said, I'm not sure exactly how to do that, but that's the general procedure I'd try.
Re: [RESOLVED] [2005] After form has loaded event?
The solution i posted above works perfectly for my situation. The user clicks a menu item "Check for update", then the a form shows, showing progress on the update-checking (establishing connection, downloading info.. etc)
Re: [RESOLVED] [2005] After form has loaded event?
I do wonder sometimes whether anyone ever uses the help documentation that Microsoft provide with Visual Studio and probably spent millions of dollars to create. The Shown event was introduced in .NET 2.0 specifically because people often wanted to do something when the form first appears. As has been stated the Activated event is raised every time the form becomes active, so to use that you generally had to use a boolean flag to indicate whether this was the first event or not. If you use the Activated event and the user activates another application then goes back to your form the whole process will be executed a second time, which is definitely NOT what you want. This means that your solution does not work perfectly in situations that you have not tested. Use the right tool for the job, which can more often than not be found by a quick perusal of the relevant help topics.
Last edited by jmcilhinney; Feb 5th, 2007 at 06:45 PM.
Re: [RESOLVED] [2005] After form has loaded event?
Originally Posted by jmcilhinney
I do wonder sometimes whether anyone ever uses the help documentation that Microsoft provide with Visual Studio and probably spent millions of dollars to create.
Not to hijack the thread, but quite honestly, I don't use it as much as some VB.NET gray-beards would think I should because it's, in my opinion, not very well written. It's almost as greek to me as a new programming language is, which is the exact oposite of what it's supposed to be. That said, if M$ spent millions of dollars to create it, I'd almost feel sorry they wasted their money.
Re: [RESOLVED] [2005] After form has loaded event?
Originally Posted by highflight1985
Not to hijack the thread, but quite honestly, I don't use it as much as some VB.NET gray-beards would think I should because it's, in my opinion, not very well written. It's almost as greek to me as a new programming language is, which is the exact oposite of what it's supposed to be. That said, if M$ spent millions of dollars to create it, I'd almost feel sorry they wasted their money.
I digress.
I've learned the vast majority of what I know from MSDN and I don't speak Greek. I'm no genius so I I can do it then anyone can. Most people just don't use it properly. I often see posts where people say "I searched but couldn't find anything". The vast majority of times there is no searching required. In this case, you want to do something when somethiung happens in a form. "When something happens" immediately means an event, so you go straight to the event listing for the Fomr class, as my previously posted image shows. Reading down the list I think that the name and description of the Shown event pretty much match the circumstances of this current request. Clicking the name takes you to the topic for that event and it includes this:
The Shown event is only raised the first time a form is displayed; subsequently minimizing, maximizing, restoring, hiding, showing, or invalidating and repainting will not raise this event.
Now that exactly matches the current requirement so that's the question answered in less than two minutes.
I'm better at using MSDN now than I was when I first started. To get the most out of it you need to practice. You won't always get what you need but you will more often than not. To just not bother is simply lazy in my opinion. I did it and it wasn't hard. Anyone who applies logic and perseverence can do it too. It's a great resource and it's made me the developer I am. It's money well spent.