Raising Events in ApplicationEvents

obrien.james

Member
Joined
Sep 11, 2009
Messages
15
Programming Experience
Beginner
Hi,

I have developed a program that I want to run as a single instance form, but I want to handle any new instances trying to occur and process their command line parameters. In the ApplicationEvents StartupNextInstance sub, I raise a custom event FSwitch().

[XCODE]Dim AppEventArgs As New ApplicationEventsArgs
AppEventArgs.FSwitch = True
AppEventArgs.FPath = FilePath
RaiseEvent FSwitch(AppEventArgs)[/XCODE]

In the programs main form's Load sub, I add a handler to the custom event:

[XCODE]AddHandler My.Application.FSwitch, AddressOf NewAutomaticEvent[/XCODE]

However, when I install the program, and go to load a new instance, the NewAutomaticEvent doesn't fire

I would try and debug this, but I don't know how to make a new instance during debugging.

I would greatly appreciate any help or advice

Thanks in advance

Jamse
 
You don't need to install the app to test this. Just run normal debug from IDE, then open the output folder (bin/Debug) with Windows Explorer and run the .exe to start next instance. StartupNextInstance event is raised in first instance that you are currently debugging.

The parameter for XCODE box for VB code is "VB" by the way.
 
Back
Top