2656f5ffa8
SVN-Revision: r1032
102 lines
3.9 KiB
C#
102 lines
3.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using System.Runtime.InteropServices;
|
|
using System.Threading;
|
|
using System.Diagnostics;
|
|
using Lskj.Control;
|
|
using Lskj.Util;
|
|
using Xilium.CefGlue;
|
|
|
|
namespace Lskj.Notice
|
|
{
|
|
static class Program
|
|
{
|
|
/// <summary>
|
|
/// 应用程序的主入口点。
|
|
/// </summary>
|
|
[STAThread]
|
|
static void Main(string[] args)
|
|
{
|
|
CefRuntime.Load();//cef浏览器模块设置加载
|
|
var mainArgs = new CefMainArgs(args);
|
|
var app = new DemoApp();
|
|
var exitCode = CefRuntime.ExecuteProcess(mainArgs, app);
|
|
var settings = new CefSettings
|
|
{
|
|
MultiThreadedMessageLoop = true,
|
|
LogSeverity = CefLogSeverity.Disable,
|
|
LogFile = "CefGlue.log",
|
|
Locale = "zh-CN"
|
|
};
|
|
CefRuntime.Initialize(mainArgs, settings, app);
|
|
try
|
|
{
|
|
bool isRunning = false;
|
|
Mutex mutex = new Mutex(true, Process.GetCurrentProcess().ProcessName, out isRunning);
|
|
|
|
if (isRunning)
|
|
{
|
|
Application.EnableVisualStyles();
|
|
AboutDevCompanion DC = new AboutDevCompanion(1, false);
|
|
DC.Run();
|
|
Application.SetCompatibleTextRenderingDefault(false);
|
|
Application.Run(new FrmMain(args));
|
|
DC.Stop();
|
|
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
|
|
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
|
mutex.ReleaseMutex();
|
|
}
|
|
else
|
|
{
|
|
//MessageUtil.Show("程序已启动.");
|
|
if (!settings.MultiThreadedMessageLoop)
|
|
{
|
|
Application.Idle += (sender, e) => { CefRuntime.DoMessageLoopWork(); };
|
|
CefRuntime.Shutdown();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// <para>说明:处理异常</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-11-22 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="ThreadExceptionEventArgs"/> instance containing the event data.</param>
|
|
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
|
{
|
|
MessageUtil.Show(e.Exception);
|
|
LogHelper.Instance.WriteError(e.Exception);
|
|
}
|
|
|
|
/// <summary>
|
|
/// <para>说明:处理异常</para>
|
|
/// <para>创建人:王一帆</para>
|
|
/// <para>创建日期:2021-07-08 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="sender">The source of the event.</param>
|
|
/// <param name="e">The <see cref="ThreadExceptionEventArgs"/> instance containing the event data.</param>
|
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
|
{
|
|
Console.WriteLine(e.ExceptionObject.ToString());
|
|
MessageUtil.Show(e.ExceptionObject.ToString());
|
|
}
|
|
class SingleApplication
|
|
{
|
|
[DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
|
|
private static extern IntPtr OpenMutex( |