Solved

WinForms not showing

Posted on 2012-03-28
3
122 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now