碰到一个问题:
需求是:对于同一个app,可以创建多个进程instance。如果一个进程instance已经启动并正在使用一个temp file, 这个temp file作为进程间exclusive使用的资源,是不允许被其他这个app的进程instance所访问的。
方法:使用System.Threading.Mutex创建系统mutex--相当于进程级别的全局变量。
In fixing。。。。。。。。。。。。。。。。。。。。。。。。。。。。
学到的:
The
System.Threading namespace provides classes and interfaces that enable multithreaded programming. In addition to classes for synchronizing thread activities and access to data (
Mutex,
Monitor,
Interlocked,
AutoResetEvent, and so on), this namespace includes a
ThreadPool class that allows you to use a pool of system-supplied threads, and a
Timer class that executes callback methods on thread pool threads.
Mutex
Monitor