forked from pcpratts2/pinac
-
Notifications
You must be signed in to change notification settings - Fork 14
/
ThreadReceiver.cs
56 lines (49 loc) · 1.34 KB
/
ThreadReceiver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
////////////////////////////////////////////////////////////////////////
// ThreadReceiver.cs: Check for new data for plotting in list
//
// version: 1.0
// description: Receive data for plotting
// author: Rushabh Ravindra Gandhi (rugandhi@syr.edu)
// language: Visual C#
////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Collections;
using System.Threading;
public class ThreadReceiver
{
public struct listdatatype
{
public int num;
public String str;
public listdatatype(int x, String y)
{
num = x;
str = y;
}
};
List<listdatatype> data = new List<listdatatype>();
public void Check()
{
listdatatype m1 = new listdatatype(1, "Data~1");
listdatatype m2 = new listdatatype(2, "Data~2");
data.Add(m1);
data.Add(m2);
while (true)
{
if (data.Count>0)
{
Thread threadObj = new Thread(new ThreadStart(parsing));
threadObj.Start();
threadObj.Join();
}
if (false) // program terminates
break;
}
}
private void parsing()
{
Console.WriteLine(data[0].num+" "+data[0].str);
data.RemoveAt(0);
}
}