mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-27 03:24:20 +01:00
Tweak temp thread creation
This commit is contained in:
parent
c6d7507a01
commit
e847fd6458
@ -27,6 +27,7 @@ namespace DS4Windows
|
|||||||
List<DS4Controls> dcs = new List<DS4Controls>();
|
List<DS4Controls> dcs = new List<DS4Controls>();
|
||||||
bool[] held = new bool[DS4_CONTROLLER_COUNT];
|
bool[] held = new bool[DS4_CONTROLLER_COUNT];
|
||||||
int[] oldmouse = new int[DS4_CONTROLLER_COUNT] { -1, -1, -1, -1 };
|
int[] oldmouse = new int[DS4_CONTROLLER_COUNT] { -1, -1, -1, -1 };
|
||||||
|
Thread tempThread;
|
||||||
//SoundPlayer sp = new SoundPlayer();
|
//SoundPlayer sp = new SoundPlayer();
|
||||||
|
|
||||||
private class X360Data
|
private class X360Data
|
||||||
@ -41,10 +42,19 @@ 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 x360task = new Task(() => { Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; x360Bus = new X360Device(); });
|
/*Task x360task = new Task(() => { Thread.CurrentThread.Priority = ThreadPriority.AboveNormal; x360Bus = new X360Device(); });
|
||||||
x360task.Start();
|
x360task.Start();
|
||||||
while (!x360task.IsCompleted)
|
while (!x360task.IsCompleted)
|
||||||
Thread.SpinWait(500);
|
Thread.SpinWait(500);
|
||||||
|
*/
|
||||||
|
tempThread = new Thread(() => { x360Bus = new X360Device(); });
|
||||||
|
tempThread.Priority = ThreadPriority.AboveNormal;
|
||||||
|
tempThread.IsBackground = true;
|
||||||
|
tempThread.Start();
|
||||||
|
while (tempThread.IsAlive)
|
||||||
|
{
|
||||||
|
Thread.SpinWait(500);
|
||||||
|
}
|
||||||
|
|
||||||
AddtoDS4List();
|
AddtoDS4List();
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ namespace DS4Windows
|
|||||||
private static EventWaitHandle threadComEvent = null;
|
private static EventWaitHandle threadComEvent = null;
|
||||||
private static bool exitComThread = false;
|
private static bool exitComThread = false;
|
||||||
public static ControlService rootHub;
|
public static ControlService rootHub;
|
||||||
|
private static Thread testThread;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The main entry point for the application.
|
/// The main entry point for the application.
|
||||||
@ -95,7 +96,10 @@ namespace DS4Windows
|
|||||||
|
|
||||||
// Create the Event handle
|
// Create the Event handle
|
||||||
threadComEvent = new EventWaitHandle(false, EventResetMode.ManualReset, SingleAppComEventName);
|
threadComEvent = new EventWaitHandle(false, EventResetMode.ManualReset, SingleAppComEventName);
|
||||||
System.Threading.Tasks.Task.Run(() => { Thread.CurrentThread.Priority = ThreadPriority.Lowest; CreateInterAppComThread(); }).Wait();
|
//System.Threading.Tasks.Task.Run(() => CreateTempWorkerThread());
|
||||||
|
//CreateInterAppComThread();
|
||||||
|
CreateTempWorkerThread();
|
||||||
|
//System.Threading.Tasks.Task.Run(() => { Thread.CurrentThread.Priority = ThreadPriority.Lowest; CreateInterAppComThread(); Thread.CurrentThread.Priority = ThreadPriority.Lowest; }).Wait();
|
||||||
|
|
||||||
//if (mutex.WaitOne(TimeSpan.Zero, true))
|
//if (mutex.WaitOne(TimeSpan.Zero, true))
|
||||||
//{
|
//{
|
||||||
@ -113,7 +117,15 @@ namespace DS4Windows
|
|||||||
threadComEvent.Close();
|
threadComEvent.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
static private void CreateInterAppComThread()
|
private static void CreateTempWorkerThread()
|
||||||
|
{
|
||||||
|
testThread = new Thread(CreateInterAppComThread);
|
||||||
|
testThread.Priority = ThreadPriority.Lowest;
|
||||||
|
testThread.IsBackground = true;
|
||||||
|
testThread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CreateInterAppComThread()
|
||||||
{
|
{
|
||||||
singleAppComThread = new BackgroundWorker();
|
singleAppComThread = new BackgroundWorker();
|
||||||
singleAppComThread.DoWork += new DoWorkEventHandler(singleAppComThread_DoWork);
|
singleAppComThread.DoWork += new DoWorkEventHandler(singleAppComThread_DoWork);
|
||||||
@ -122,9 +134,9 @@ namespace DS4Windows
|
|||||||
|
|
||||||
static private void singleAppComThread_DoWork(object sender, DoWorkEventArgs e)
|
static private void singleAppComThread_DoWork(object sender, DoWorkEventArgs e)
|
||||||
{
|
{
|
||||||
|
Thread.CurrentThread.Priority = ThreadPriority.Lowest;
|
||||||
BackgroundWorker worker = sender as BackgroundWorker;
|
BackgroundWorker worker = sender as BackgroundWorker;
|
||||||
WaitHandle[] waitHandles = new WaitHandle[] { threadComEvent };
|
WaitHandle[] waitHandles = new WaitHandle[] { threadComEvent };
|
||||||
Thread.CurrentThread.Priority = ThreadPriority.Lowest;
|
|
||||||
|
|
||||||
while (!exitComThread)
|
while (!exitComThread)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user