Results 1 to 7 of 7

Thread: How to prevent opening of two instances?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    128

    How to prevent opening of two instances?

    Hi,

    What's the best way to prevent opening of two instances (or more) of the application?

    Thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to prevent opening of two instances?

    Check the single-instance box in the project property pages.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    128

    Re: How to prevent opening of two instances?

    Thanks. Where is it exactly? I can't find it...

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to prevent opening of two instances?

    Is this a Windows Forms Application project, as I am assuming? If so the box is there in the project properties and if you look you'll find it. If it's not a WinForms app then there is no such box and you'd have to handle it manually.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    128

    Re: How to prevent opening of two instances?

    OK, I see that I have to enable application framework and then I can set the single instance.
    What is the affect of "enable application framework"?

    You can see that I'm a newbie in VB.NET. I'm coming from VB6 and C++

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to prevent opening of two instances?

    The application framework should be enabled by default for new projects. Was your project upgraded from VB6 or VB.NET 2002/2003? If not then you must have disabled the application framework explicitly.

    The application framework exists to do things like this. It will manage single-instance apps, splash screens, etc. for you so you don't have to write fiddly code to perform common application-based tasks. With the framework enabled the Main method is hidden from you and you handle application-level events, e.g. Startup and Shutdown, to do things that you would otherwise have done in the Main method.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2009
    Posts
    128

    Re: How to prevent opening of two instances?

    OK, I see that I have to enable application framework and then I can set the single instance.
    What is the affect of "enable application framework"?

    You can see that I'm a newbie in VB.NET. I'm coming from VB6 and C++

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width