Skip to content

Commit

Permalink
Change thread affinity of BackgroundWorker
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryochan7 committed Aug 28, 2017
1 parent c8809f3 commit 1fedb61
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
7 changes: 4 additions & 3 deletions DS4Windows/DS4Control/ControlService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ public ControlService()
{
//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();

Expand Down
16 changes: 8 additions & 8 deletions DS4Windows/DS4Forms/DS4Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -919,19 +919,19 @@ protected void ShowNotification(object sender, string text)

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);
Expand Down
2 changes: 1 addition & 1 deletion DS4Windows/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static void Main(string[] args)

// 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))
//{
Expand Down

0 comments on commit 1fedb61

Please sign in to comment.