Change thread affinity of BackgroundWorker

This commit is contained in:
Travis Nickles 2017-08-27 21:26:36 -05:00
parent c8809f37cb
commit 1fedb61d2b
3 changed files with 13 additions and 12 deletions

View File

@ -41,9 +41,10 @@ namespace DS4Windows
{ {
//sp.Stream = Properties.Resources.EE; //sp.Stream = Properties.Resources.EE;
// Cause thread affinity to not be tied to main GUI thread // Cause thread affinity to not be tied to main GUI thread
Task.Run(() => { Task x360task = new Task(() => { Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; x360Bus = new X360Device(); });
Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; x360task.Start();
x360Bus = new X360Device(); }).Wait(); while (!x360task.IsCompleted)
Thread.SpinWait(500);
AddtoDS4List(); AddtoDS4List();

View File

@ -919,19 +919,19 @@ namespace DS4Windows
protected void Form_Resize(object sender, EventArgs e) protected void Form_Resize(object sender, EventArgs e)
{ {
if (FormWindowState.Minimized == this.WindowState) if (FormWindowState.Minimized == WindowState)
{ {
this.Hide(); Hide();
this.ShowInTaskbar = false; ShowInTaskbar = false;
this.FormBorderStyle = FormBorderStyle.None; FormBorderStyle = FormBorderStyle.None;
} }
else if (FormWindowState.Normal == this.WindowState) else if (FormWindowState.Normal == WindowState)
{ {
//mAllowVisible = true; //mAllowVisible = true;
this.Show(); Show();
this.ShowInTaskbar = true; ShowInTaskbar = true;
this.FormBorderStyle = FormBorderStyle.Sizable; FormBorderStyle = FormBorderStyle.Sizable;
} }
chData.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); chData.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);

View File

@ -95,7 +95,7 @@ namespace DS4Windows
// Create the Event handle // Create the Event handle
threadComEvent = new EventWaitHandle(false, EventResetMode.ManualReset, SingleAppComEventName); threadComEvent = new EventWaitHandle(false, EventResetMode.ManualReset, SingleAppComEventName);
CreateInterAppComThread(); System.Threading.Tasks.Task.Run(() => { Thread.CurrentThread.Priority = ThreadPriority.Lowest; CreateInterAppComThread(); }).Wait();
//if (mutex.WaitOne(TimeSpan.Zero, true)) //if (mutex.WaitOne(TimeSpan.Zero, true))
//{ //{