Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

duplicate instance

Status
Not open for further replies.

cccruz18

Programmer
Jun 11, 2002
16
PH
Hi!

Help please! My VB application is running through Microsoft Scheduler. My problem is that there are times that the application is manually opened thus having duplicate instance - one in scheduler and one manually opened. How can I prevent this? I've tried using preinstance but it seems that this is only used if the application is opened manually twice.



Ann
 
Hi Ann:

Suspect that you may be able to use:

Code:
    If App.PrevInstance Then Unload Me

in your start-up code.

Cassie
 
Hi!
Yes. Already tried PrevInstance. It seems that the command does not work in Microsoft Scheduler. Is there any other way to trap duplicate instance?
Thanks.
Ann
 
Actually, you need to use previousinstance within the vb application itself...

In your VB app's main or frmMain or whatever form is first to be displayed or loaded, put the call in the form_load event.

It shouldn't matter how or when the vb application is started, be it manually or by any scheduling app.

Cassie was correct... Tuna - It's fat free until you add the Mayo!
 
Hi!

Rephrasing my question: What I mean is I have already inserted PrevInstance in my VB Application.

Private Sub Form_Load()
If App.PrevInstance Then Unload Me
End Sub

When compiled, add .exe to the scheduled task that runs everyday and closes after completing a process.

However, there are cases while the application is running in scheduled task, users intend to open using programs then application or double click application. This causes duplicate instances. How can I prevent this? Please help.

Thanks.
Ann
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top