using Lskj.Control;
using Lskj.Util;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using Xilium.CefGlue;
namespace Lskj.QuickModule
{
static class Program
{
///
/// 应用程序的主入口点。
///
[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();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain(args));
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)
{
}
}
///
/// 说明:处理异常
/// 创建人:龚宇超
/// 创建日期:2017-11-22
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
{
MessageUtil.Show(e.Exception);
LogHelper.Instance.WriteError(e.Exception);
}
///
/// 说明:处理异常
/// 创建人:王一帆
/// 创建日期:2021-07-08
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The source of the event.
/// The instance containing the event data.
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Console.WriteLine(e.ExceptionObject.ToString());
MessageUtil.Show(e.ExceptionObject.ToString());
}
internal sealed class DemoApp : CefApp
{
protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
{
commandLine.AppendSwitch("ppapi-flash-version", "28.0.0.137");
commandLine.AppendSwitch("ppapi-flash-path", @"D:\测试\LSERP\Debug\pepflashplayer.dll");
}
}
}
}