Commit 9fa6409f authored by SherryChaos's avatar SherryChaos

Send a message every 0.1 seconds

parent 959ac6b9
This diff is collapsed.
...@@ -25,11 +25,14 @@ namespace MDPro3 ...@@ -25,11 +25,14 @@ namespace MDPro3
public static List<Package> packagesInRecord = new List<Package>(); public static List<Package> packagesInRecord = new List<Package>();
private static readonly Queue<Package> messageQueue = new Queue<Package>(); private static readonly Queue<Package> messageQueue = new Queue<Package>();
static Thread senderThead;
public static void InitializeSender() public static void InitializeSender()
{ {
try try
{ {
var senderThead = new Thread(Sender); senderThead?.Abort();
senderThead = new Thread(Sender);
senderThead.IsBackground = true; senderThead.IsBackground = true;
senderThead.Start(); senderThead.Start();
} }
...@@ -252,7 +255,10 @@ namespace MDPro3 ...@@ -252,7 +255,10 @@ namespace MDPro3
lock (locker) lock (locker)
{ {
if (messageQueue.Count == 0) if (messageQueue.Count == 0)
{
senderThead.Join(100);
continue; continue;
}
currentMessage = messageQueue.Dequeue(); currentMessage = messageQueue.Dequeue();
} }
try try
......
...@@ -1496,6 +1496,7 @@ namespace MDPro3 ...@@ -1496,6 +1496,7 @@ namespace MDPro3
psum = false; psum = false;
greenBackground.gameObject.SetActive(false); greenBackground.gameObject.SetActive(false);
inputMode = false;
} }
public void AddPackage(Package p) public void AddPackage(Package p)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment