mutexes Implement process Exclusive resources

Source: Internet
Author: User
Tags mutex

Background: Develop a set of hardware-dependent software that allows only one software process to run in a single time to avoid hardware resource invocation conflicts.

Method: Use a mutex to determine if the software is started, and if so, to close the software that is about to start.

Code:

1 Static class Program2     {3         /// <summary>4         ///The main entry point for the application.5         /// </summary>6         StaticMutex _mutex;7 8 [STAThread]9         Static voidMain ()Ten         { One             BOOLfirstinstance; A_mutex =NewMutex (false,"DFS. Pos. Checkcashing", outfirstinstance); -             if(!firstinstance) -                 return; the  -              -         } -}

mutexes Implement process Exclusive resources

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.