static void Main() { logger = LogManager.GetCurrentClassLogger(); AppDomain.CurrentDomain.UnhandledException += (o, a) => { Exception ex = null; var obj = a.ExceptionObject; if (obj != null) { ex = obj as Exception; logger.Fatal(ex); } if (ex != null) { logger.Fatal(ex); } else { logger.Fatal("FATAL ERROR!!!"); } Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }; logger.Info("========== START ============"); var winVersion = Environment.OSVersion.Version; bool isCompatibleOSVersion = (winVersion.Major >= 6 && winVersion.Minor >= 2); if (!isCompatibleOSVersion) { logger.Fatal("Windows versions earlier than 8 are not supported."); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); } InitMediaLib(); Shcore.SetProcessPerMonitorDpiAwareness(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm form = new MainForm(); Application.Run(form); ShutdownMediaLib(); logger.Info("========== THE END ============"); //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new MainForm()); }
static void Main() { MediaToolkitManager.Startup(); //DwmApi.DisableAero(true); Shcore.SetProcessPerMonitorDpiAwareness(); WinMM.timeBeginPeriod(1); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form2()); WinMM.timeEndPeriod(1); }
public static int Main(string[] args) { int exitCode = 0; InitLogger(); logger.Info("============================ START ============================"); bool createdNew = false; Mutex mutex = null; try { mutex = new Mutex(true, AppConsts.ApplicationId, out createdNew); if (!createdNew) { logger.Info("Another instance is already running..."); if (!Models.AppModel.AllowMutipleInstance) { var res = Services.WndProcService.ShowAnotherInstance(); return(0); //return -1; //... } } StartupParams = StartupParameters.Create(args); logger.Info(StartupParams.GetSysInfo()); try { MediaToolkitManager.Startup(); Shcore.SetProcessPerMonitorDpiAwareness(); var application = new App(); application.DispatcherUnhandledException += Application_DispatcherUnhandledException; application.InitializeComponent(); logger.Info("============================ RUN ============================"); application.Run(); } finally { MediaToolkitManager.Shutdown(); } } catch (Exception ex) { ProcessError(ex); } finally { if (mutex != null) { if (createdNew) { mutex.ReleaseMutex(); } mutex.Dispose(); } logger.Info("============================ THE END ============================"); } return(exitCode); }
static void Main(string[] args) { InitLogger(); logger.Info("========== START ============"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; StartupParams = StartupParameters.Create(args); //if (StartupParams.RunAsSystem) //{ // if (StartupParams.IsElevated) // { // if (RestartAsSystem() > 0) // { // return; // } // logger.Warn("Restart failed..."); // } // else // { // RunAsSystem(); // } //} if (StartupParams.IsElevated) { if (!StartupParams.NoRestart) {//Restart application with system permissions... if (RestartAsSystem() > 0) { return; } logger.Warn("Restart failed..."); // открываем процесс как обычно... //TODO:... } } bool createdNew = false; Mutex mutex = null; try { mutex = new Mutex(true, AppConsts.ApplicationId, out createdNew); if (!createdNew) { logger.Info("Another instance is already running..."); //... } bool tempMode = !createdNew; Config.Initialize(tempMode); MediaToolkitManager.Startup(); //DwmApi.DisableAero(true); Shcore.SetProcessPerMonitorDpiAwareness(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm form = new MainForm(); logger.Info("========== RUN ============"); Application.Run(form); } finally { Config.Shutdown(); MediaToolkitManager.Shutdown(); if (mutex != null) { if (createdNew) { mutex.ReleaseMutex(); } mutex.Dispose(); } logger.Info("========== THE END ============"); } }
static void Main(string[] args) { //Console.Title = "App started..."; logger = LogManager.GetCurrentClassLogger(); logger.Info("========== START ============"); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; bool createdNew = false; Mutex mutex = null; try { //mutex = new Mutex(true, AppConsts.ApplicationId, out createdNew); //if (!createdNew) //{ // logger.Info("Another instance is already running..."); // //... //} if (args != null && args.Length > 0) {//... } bool tempMode = !createdNew; //ScreenStreamer.WinForms.App.Config.Initialize(tempMode); MediaToolkitManager.Startup(); //DwmApi.DisableAero(true); Shcore.SetProcessPerMonitorDpiAwareness(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //var screen0 = Screen.AllScreens[0]; ////var bound0 = SystemInformation.VirtualScreen;//screen0.Bounds;//new System.Drawing.Rectangle(10, 10, 100, 100); // ////var bound0 = screen0.Bounds;//new System.Drawing.Rectangle(10, 10, 100, 100); // //var bound0 = new System.Drawing.Rectangle(10, 10, 100, 100); // //var src0 = new ScreenSource(); //var capture0 = new ScreenCaptureDevice //{ // CaptureRegion = bound0, // Resolution = bound0.Size, // Name = screen0.DeviceName, // DisplayRegion = bound0, // Properties = new ScreenCaptureProperties // { // UseHardware = true, // CaptureType = VideoCaptureType.DXGIDeskDupl, // AspectRatio = true, // Fps = 30, // } //}; //src0.Setup(capture0); //src0.Start(); //var screen1 = Screen.AllScreens[1]; ////var bound1 = screen1.Bounds;//new System.Drawing.Rectangle(-1920, 10, 10, 10); // //var bound1 = new System.Drawing.Rectangle(-1920, 10, 10, 10); // //var capture1 = new ScreenCaptureDevice //{ // CaptureRegion = bound1, // Resolution = bound1.Size, // Name = screen1.DeviceName, // DisplayRegion = bound1, // Properties = new ScreenCaptureProperties // { // UseHardware = true, // CaptureType = VideoCaptureType.DXGIDeskDupl, // AspectRatio = true, // Fps = 30, // } //}; //var src1 = new ScreenSource(); //src1.Setup(capture1); //src1.Start(); //ScreenStreamer.WinForms.App.MainForm form = new ScreenStreamer.WinForms.App.MainForm(); MainForm form = new MainForm(); Application.Run(form); } finally { // ScreenStreamer.WinForms.App.Config.Shutdown(); MediaToolkitManager.Shutdown(); if (mutex != null) { if (createdNew) { mutex.ReleaseMutex(); } mutex.Dispose(); } logger.Info("========== THE END ============"); } }