Solved

WinForms not showing

Posted on 2012-03-28
3
129 Views
Last Modified: 2013-02-12
I have an application that I designed in VB.net.  What I am trying to do is upon clicking the exit button in my application I want another WIndows Form to show and perform my "backup procedure".  The situation is the backup procedure works and takes about15 seconds to complete.  However the form does not show up.  The main form just stays on the screen, and then after the backup conmpletes the program exits (which is what it is supposed to do upon completion of backup procedure).  

I want the backup form to show while it is doing the backup procedure because there is a progress bar on there that I want to display, of course, the progress of the backup.  How can I get the form to display without just executing tyhe code and not showing the form?  I have a frmBackup.SHOW and I have tried frmBackup.ShowDialog() but nothing shows the form.  It is loading because the form contains the backup procedure and it is running.

Any help is greatly appreciated.
0
Comment
Question by:JasonJasonJasonJason
3 Comments
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 37780313
Sounds like you need to move the actual backup code into another thread.  The BackgroundWorker() control is the easiest way to do this.

If you have a long running loop, however, you might be able to get away with simply placing Application.DoEvents() inside that loop.
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37780526
Move the entire backup code to this new form, add progress bar in this form and add a backgroundworker to start backup in background.

Here is an example on how to use backgroundworker and progressbar together:-
http://www.dotnetperls.com/progressbar
http://www.codeproject.com/Tips/83317/BackgroundWorker-and-ProgressBar-demo

Don't let the form return until the job is complete.
Also open this form on form_closing event of your parent form in frmBackup.ShowDialog();
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 500 total points
ID: 37781613
Good suggestions above. If you move the backup code from Form.Load event to Form.Shown event, you form will show before the backup code executes. But for the progressbar to work, you would need to do some multithreading/backgroundworker.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question