WindowsFormsApplicationBase equivalent in C#

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

Hi! Do not ask me why I was given the task of removing references to VB.NET
in the app. The VB.NET reference was added to use WindowsFormsApplicationBase
class and its two methods:

OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)

I can not seem to find a replacement for these in C#.

Any ideas/thoughts/suggestions are greatly appreciated.

Thank you in advance,
 
Mike said:
Hi! Do not ask me why I was given the task of removing references to VB.NET
in the app.

Probably because someone wants the program to be "pure .NET"; that is,
not using language-specific features.
The VB.NET reference was added to use WindowsFormsApplicationBase
class and its two methods:

OnStartup(Microsoft.VisualBasic.ApplicationServices.StartupEventArgs e)
OnStartupNextInstance(StartupNextInstanceEventArgs eventArgs)

I can not seem to find a replacement for these in C#.

Any ideas/thoughts/suggestions are greatly appreciated.

If I recall correctly, the "next instance" is related to VB's support
for single-instance apps. There's nothing built into .NET at the moment
for that. But there are lots of examples on the Internet, using a named
instance of the Mutex class to detect previously started instances.

The basic "on startup" logic can be handled in a couple of places:
either in your Program class's Main() method, or in your main Form's
initialization (e.g. constructor, OnShown() override, etc.)

Of course, what code you put in those places will depend on exactly what
it is you're trying to do. It's one thing to know that your program is
starting up, or that there's already another instance of it running.
It's yet another to act on that knowledge. :)

Pete
 
Back
Top