Solved

WinForms not showing

Posted on 2012-03-28
3
128 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
send messages to whatsapp programatically 2 48
Close form "before" open 3 40
Sql server insert 13 31
How to seperate number and letters from a string 3 11
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

810 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