Esempio n. 1
0
        public LogViewModel(DS4Windows.ControlService service)
        {
            string version = DS4Windows.Global.exeversion;

            logItems.Add(new LogItem {
                Datetime = DateTime.Now, Message = $"DS4Windows version {version}"
            });
            logItems.Add(new LogItem {
                Datetime = DateTime.Now, Message = $"DS4Windows Assembly Architecture: {(Environment.Is64BitProcess ? "x64" : "x86")}"
            });
            logItems.Add(new LogItem {
                Datetime = DateTime.Now, Message = $"OS Version: {Environment.OSVersion}"
            });
            logItems.Add(new LogItem {
                Datetime = DateTime.Now, Message = $"OS Product Name: {DS4Windows.Util.GetOSProductName()}"
            });
            logItems.Add(new LogItem {
                Datetime = DateTime.Now, Message = $"OS Release ID: {DS4Windows.Util.GetOSReleaseId()}"
            });
            logItems.Add(new LogItem {
                Datetime = DateTime.Now, Message = $"System Architecture: {(Environment.Is64BitOperatingSystem ? "x64" : "x32")}"
            });

            //logItems.Add(new LogItem { Datetime = DateTime.Now, Message = "DS4Windows version 2.0" });
            //BindingOperations.EnableCollectionSynchronization(logItems, _colLockobj);
            BindingOperations.EnableCollectionSynchronization(logItems, _logListLocker, LogLockCallback);
            service.Debug += AddLogMessage;
            DS4Windows.AppLogger.GuiLog += AddLogMessage;
        }
Esempio n. 2
0
 private static void createControlService()
 {
     controlThread              = new Thread(() => { rootHub = new ControlService(); });
     controlThread.Priority     = ThreadPriority.Normal;
     controlThread.IsBackground = true;
     controlThread.Start();
     while (controlThread.IsAlive)
     {
         Thread.SpinWait(500);
     }
 }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("he");
            foreach (string s in args)
            {
                if (s == "driverinstall" || s == "-driverinstall")
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new WelcomeDialog());
                    return;
                }
            }
            System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.LowLatency;

            try
            {
                Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.High;
            }
            catch
            {
                // Ignore problems raising the priority.
            }
            try
            {
                // another instance is already running if OpenExsting succeeds.
                threadComEvent = EventWaitHandle.OpenExisting(SingleAppComEventName);
                threadComEvent.Set(); // signal the other instance.
                threadComEvent.Close();
                return;               // return immediatly.
            }
            catch { /* don't care about errors */ }
            // Create the Event handle
            threadComEvent = new EventWaitHandle(false, EventResetMode.AutoReset, SingleAppComEventName);
            CreateInterAppComThread();
            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                rootHub = new ControlService();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new DS4Form(args));
                mutex.ReleaseMutex();
            }

            // End the communication thread.
            singleAppComThread.CancelAsync();
            while (singleAppComThread.IsBusy)
            {
                Thread.Sleep(50);
            }
            threadComEvent.Close();
        }
Esempio n. 4
0
 private static void createControlService()
 {
     controlThread = new Thread(() => {
         rootHub      = new ControlService();
         collectTimer = new System.Threading.Timer(GarbageTask, null, 30000, 30000);
     });
     controlThread.Priority     = ThreadPriority.Normal;
     controlThread.IsBackground = true;
     controlThread.Start();
     while (controlThread.IsAlive)
     {
         Thread.SpinWait(500);
     }
 }
Esempio n. 5
0
        static void Main(string[] args)
        {
            //Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("he");
            for (int i = 0, argsLen = args.Length; i < argsLen; i++)
            {
                string s = args[i];
                if (s == "driverinstall" || s == "-driverinstall")
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new WelcomeDialog());
                    return;
                }
                else if (s == "re-enabledevice" || s == "-re-enabledevice")
                {
                    try
                    {
                        i++;
                        string deviceInstanceId = args[i];
                        DS4Devices.reEnableDevice(deviceInstanceId);
                        Environment.ExitCode = 0;
                        return;
                    }
                    catch (Exception)
                    {
                        Environment.ExitCode = Marshal.GetLastWin32Error();
                        return;
                    }
                }
                else if (s == "runtask" || s == "-runtask")
                {
                    TaskService ts     = new TaskService();
                    Task        tasker = ts.FindTask("RunDS4Windows");
                    if (tasker != null)
                    {
                        tasker.Run("");
                    }

                    Environment.ExitCode = 0;
                    return;
                }
            }

            System.Runtime.GCSettings.LatencyMode = System.Runtime.GCLatencyMode.LowLatency;

            try
            {
                Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.High;
            }
            catch
            {
                // Ignore problems raising the priority.
            }

            try
            {
                // another instance is already running if OpenExsting succeeds.
                threadComEvent = EventWaitHandle.OpenExisting(SingleAppComEventName);
                threadComEvent.Set(); // signal the other instance.
                threadComEvent.Close();
                return;               // return immediatly.
            }
            catch { /* don't care about errors */ }

            // Create the Event handle
            threadComEvent = new EventWaitHandle(false, EventResetMode.AutoReset, SingleAppComEventName);
            CreateInterAppComThread();

            if (mutex.WaitOne(TimeSpan.Zero, true))
            {
                rootHub = new ControlService();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new DS4Form(args));
                mutex.ReleaseMutex();
            }

            // End the communication thread.
            singleAppComThread.CancelAsync();
            while (singleAppComThread.IsBusy)
            {
                Thread.Sleep(50);
            }
            threadComEvent.Close();
        }