本文整理汇总了C#中System.Threading.Mutex.ReleaseMutex方法的典型用法代码示例。如果您正苦于以下问题:C# System.Threading.Mutex.ReleaseMutex方法的具体用法?C# System.Threading.Mutex.ReleaseMutex怎么用?C# System.Threading.Mutex.ReleaseMutex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.Mutex
的用法示例。
在下文中一共展示了System.Threading.Mutex.ReleaseMutex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main()
{
bool activo;
System.Threading.Mutex m = new System.Threading.Mutex(true, "LimpiezasPalmeralForms", out activo);
if (!activo)
{
MessageBox.Show("Ya se ha iniciado la aplicación");
Application.Exit();
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
try
{
//Application.Run(new Login());
Application.Run(new PantallaPrincipal());
}
catch (Exception ex)
{
System.Console.WriteLine(ex.Message.ToString() + '\n' + ex.StackTrace);
}
}
// Se libera la exclusión mutua
m.ReleaseMutex();
}
示例2: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
bool result;
var mutex = new System.Threading.Mutex(true, "IMgmt", out result);
try
{
if (!result)
{
MessageBox.Show("Another instance is already running.");
return;
}
if (!EventLog.SourceExists(sSource))
EventLog.CreateEventSource(sSource, sLog);
Application.Run(new frmSplash());
GC.KeepAlive(mutex);
}
catch (Exception ex)
{
EventLog.WriteEntry("Inventory Mgmt", ex.Message + ":" + ex.InnerException + ":" + ex.StackTrace.ToString());
}
finally
{
mutex.ReleaseMutex();
}
}
示例3: Main
static void Main()
{
bool SingleApp = bool.Parse(System.Configuration.ConfigurationManager.AppSettings["SingleApp"]);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (!SingleApp)
{
Application.Run(new Form1());
}
else
{
bool bExist = false;
System.Threading.Mutex mm = new System.Threading.Mutex(true, "IntServer", out bExist);
if (bExist)
{
Application.Run(new Form1());
mm.ReleaseMutex();
}
else
{
//查找窗体
IntPtr handle = WindowAPI.FindWindow(null, "WIFI-COM网络数据调试工具");
if (handle != IntPtr.Zero)
{
//恢复窗口并设置为前台窗口
WindowAPI.SetForegroundWindow(handle);
WindowAPI.OpenIcon(handle);
//PostMessage(handle, WM_SYSCOMMAND, (IntPtr)SC_DEFAULT, IntPtr.Zero);
}
}
}
}
示例4: Button_Click
private void Button_Click(object sender, RoutedEventArgs e)
{
xml_data.Document.Blocks.Clear();
string file = filename_edit.Text;
bool timeout = false;
bool initial_owned;
System.Threading.Mutex shm_mutex = new System.Threading.Mutex(true, "Global\\" + file + "_mutex", out initial_owned);
if (!initial_owned)
{
bool mutex_is_free = shm_mutex.WaitOne(50);
if (mutex_is_free == false)
{
timeout = true;
return;
}
}
else
{
shm_mutex.ReleaseMutex();
shm_mutex.Dispose();
return;
}
if (timeout)
return;
string text_xml = "";
using (var shm = System.IO.MemoryMappedFiles.MemoryMappedFile.OpenExisting(file, System.IO.MemoryMappedFiles.MemoryMappedFileRights.Read))
{
using (var read_stream = shm.CreateViewStream(0,0, System.IO.MemoryMappedFiles.MemoryMappedFileAccess.Read))
{
System.IO.StreamReader reader = new System.IO.StreamReader(read_stream);
text_xml = reader.ReadToEnd();
text_xml = text_xml.Trim('\0');
}
}
shm_mutex.ReleaseMutex();
xml_data.Document.Blocks.Add(new Paragraph(new Run(text_xml)));
}
示例5: Main
static void Main()
{
bool isLaunched;
System.Threading.Mutex mutex = new System.Threading.Mutex(true, "OnlyRunOneInstance", out isLaunched);
if (isLaunched)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
mutex.ReleaseMutex();
}
else
{
}
}
示例6: Main
static void Main() {
var mutex = new System.Threading.Mutex( false, Application.ExecutablePath.Replace( '\\', '/' ) );
if ( !mutex.WaitOne( 0, false ) ) {
// 多重起動禁止
MessageBox.Show( Properties.Resources.SoftwareName + Properties.Resources.Version + Properties.Resources.NoMultipleStart, Properties.Resources.SoftwareName + Properties.Resources.Version, MessageBoxButtons.OK, MessageBoxIcon.Error );
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault( false );
Application.Run( new FormMain() );
mutex.ReleaseMutex();
}
示例7: Main
static void Main()
{
var mutex = new System.Threading.Mutex( false, Application.ExecutablePath.Replace( '\\', '/' ) );
if ( !mutex.WaitOne( 0, false ) ) {
// 多重起動禁止
MessageBox.Show( "既に起動しています。\r\n多重起動はできません。", "七四式電子観測儀", MessageBoxButtons.OK, MessageBoxIcon.Error );
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault( false );
Application.Run( new FormMain() );
mutex.ReleaseMutex();
}
示例8: Main
static void Main()
{
bool runone;
System.Threading.Mutex run = new System.Threading.Mutex(true, "xinbiao_a_test", out runone);
if (runone)
{
run.ReleaseMutex();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new TinyVpnUI());
}
else
{
//MessageBox.Show("已经运行了一个实例了。");
Application.Exit();//退出程
}
}
示例9: Main
static void Main()
{
bool isNotRunning = false;
System.Threading.Mutex mu = new System.Threading.Mutex(true, "WarKeyRunning", out isNotRunning);
if (isNotRunning)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new frmWarKey());
mu.ReleaseMutex();
}
else
{
MessageBox.Show("程序已在运行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
示例10: Main
static void Main()
{
bool ret = false;
System.Threading.Mutex running = new System.Threading.Mutex(true, Application.ProductName, out ret);
if (ret)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
running.ReleaseMutex();
}
else
{
MessageBox.Show("程序已经在运行,请不要同时运行多个本程序!", "提示!", MessageBoxButtons.OK, MessageBoxIcon.Information);
Application.Exit();
}
}
示例11: Main
static void Main()
{
Boolean createdNew; //返回是否赋予了使用线程的互斥体初始所属权
DevExpress.UserSkins.BonusSkins.Register();
DevExpress.UserSkins.OfficeSkins.Register();
DevExpress.Skins.SkinManager.EnableFormSkins();
DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(Properties.Settings.Default.DefaultSkinName);
System.Threading.Mutex instance = new System.Threading.Mutex(true, "ArresterSerialPort", out createdNew); //同步基元变量
if (createdNew)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
instance.ReleaseMutex();
}
}
示例12: Application_Startup
private void Application_Startup(object sender, StartupEventArgs e)
{
bool runone;
run = new System.Threading.Mutex(true, "App_" + "CarryBag", out runone);
if (!runone)
{
Application.Current.Shutdown();
return;
}
Application currApp = Application.Current;
currApp.StartupUri = new Uri("MainWindow.xaml", UriKind.RelativeOrAbsolute);
run.ReleaseMutex();
}
示例13: Main
static void Main()
{
System.Threading.Mutex mutex = new System.Threading.Mutex(false, "A-Go_Calc");
if (mutex.WaitOne(0, false))
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
mutex.ReleaseMutex();
}
else
{
if (!WakeupWindow())
System.Windows.Forms.MessageBox.Show("あ号進行度計算機は起動しています");
}
}
示例14: Main
static void Main()
{
//Mutexクラスの作成
//"MyName"の部分を適当な文字列に変えてください
System.Threading.Mutex mutex = new System.Threading.Mutex(false, "mooEditor");
//ミューテックスの所有権を要求する
if (mutex.WaitOne(0, false) == false)
{
//すでに起動していると判断して終了
return;
}
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new mooEditor());
//ミューテックスを解放する
mutex.ReleaseMutex();
}
示例15: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
bool bRun = true;
System.Threading.Mutex mut = new System.Threading.Mutex(true, "NTIIntelaTranc", out bRun);
string AppStr = Application.StartupPath;
string name = @"\imc_nti.exe";
CheckProcess(AppStr+name,ref bRun);
if (bRun)
{
Application.Run(new Log());
mut.ReleaseMutex();
}
else
{
MessageBox.Show("已启动程序,不可以重复启动!");
Application.Exit();
}
}