WPF outsourcing company-technology sharing WPF only runs one instance

Source: Internet
Author: User

First, reference Microsoft. VisualBasic
Create a class single
Public class single: Microsoft. VisualBasic. applicationservices. windowsformsapplicationbase
{
APP;
Public single ()
{
This. issingleinstance = true;
}
Protected override bool onstartup (Microsoft. VisualBasic. applicationservices. startupeventargs eventargs)
{
A = new app ();
A. initializecomponent ();
A. Run ();
Return false;
}
Protected override void onstartupnextinstance (Microsoft. VisualBasic. applicationservices. startupnextinstanceeventargs eventargs)
{
Base. onstartupnextinstance (eventargs );
A. Activate ();
}
}

App. CS
Public partial class app: Application
{
Protected override void onstartup (startupeventargs E)
{
Base. onstartup (E );
Window1 W = new window1 ();
W. Show ();
}
Public void activate ()
{
Mainwindow. Activate ();
}
Private void application_sessionending (Object sender, sessionendingcanceleventargs E)
{

}
Private void application_startup (Object sender, startupeventargs E)
{

}
Private void application_exit (Object sender, exiteventargs E)
{

}
}
App. G. CS
[System. stathreadattribute ()]
[System. Diagnostics. debuggernonusercodeattribute ()]
Public static void main (string [] ){
Single S = new single ();
S. Run ();
}
 

 

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.