C #. Net client CS program can only be started once

Source: Internet
Author: User

Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Windows. forms;
Using Microsoft. VisualBasic. applicationservices;

Namespace myquery. myie
{
Static class Program
{
/// <Summary>
/// Main entry point of the application.
/// </Summary>
[Stathread]
Static void main ()
{
Application. enablevisualstyles ();
Application. setcompatibletextrenderingdefault (false );
Singleinstancemanager manager = new singleinstancemanager (); // Single Instance Manager
Manager. Run (New String [] {});
// Application. Run (New frmbrower ());
}
}
Public class singleinstancemanager: windowsformsapplicationbase
{
Frmbrower app;
Public singleinstancemanager ()
{
This. issingleinstance = true;
}

Protected override bool onstartup (Microsoft. VisualBasic. applicationservices. startupeventargs E)
{
APP = new frmbrower ();
Application. Run (APP );
Return false;
}

Protected override void onstartupnextinstance (startupnextinstanceeventargs eventargs)
{
Base. onstartupnextinstance (eventargs );
App. Activate ();
MessageBox. Show ("the client program is already running and cannot be run repeatedly", "warning", messageboxbuttons. OK, messageboxicon. Stop); // prompt a dialog box
}

}
}
Welcome to: http: // 121.18.78.216, which is a demonstration platform for ease of query and analysis, workflow, content management, and project management.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.