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;
// Cause thread affinity to not be tied to main GUI thread
Task.Run(() => {
Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
x360Bus = new X360Device(); }).Wait();
Task x360task = new Task(() => { Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; x360Bus = new X360Device(); });
x360task.Start();
while (!x360task.IsCompleted)
Thread.SpinWait(500);
AddtoDS4List();

View File

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

View File

@ -95,7 +95,7 @@ namespace DS4Windows
// Create the Event handle
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))
//{