I have a windows service. The windows service has 2 files. Winsowsservice.cs and Thread.cs.
The windowsservice receives a byte array converts it to a string and passes it to a thread instance in the thread.cs file. Here is the code:
byte[] b=new byte[1024];
int k=s.Receive(b);
Console.WriteLine("Recieved...");
ASCIIEncoding encoding = new ASCIIEncoding( );
string cs = encoding.GetString(b);
MyThread thr1 = new MyThread(cs);
MyThread thr2 = new MyThread(cs);
// I get an error message here: No overload for method 'MyThread' takes '1' argument
I am trying to pass the cs string how do I pass multiple messages?
Thread tid1 = new Thread(new ThreadStart(thr1.Thread1(cs)));
Thread tid2 = new Thread(new ThreadStart(thr2.Thread1(cs)));
// I get an error message saying: Method name expected
In the thread.cs file I declare a thread1 function and try to process the cs string that's passed from the serviceexample.cs file:
public void Thread1(string x)
{
for (int i = 0; i < 10; i++)
{
Thread thr = Thread.CurrentThread;
Console.WriteLine(thr.Name + "=" + i);
Thread.Sleep(1);
string[] array = cs.Replace("\\n", "\n").Replace("\0", "").TrimEnd().Split('\n');
// I get an error message at the last line: The type or namespace name 'cs' could not be found (are you missing a using directive or an assembly reference?)
Thank you
The windowsservice receives a byte array converts it to a string and passes it to a thread instance in the thread.cs file. Here is the code:
byte[] b=new byte[1024];
int k=s.Receive(b);
Console.WriteLine("Recieved...");
ASCIIEncoding encoding = new ASCIIEncoding( );
string cs = encoding.GetString(b);
MyThread thr1 = new MyThread(cs);
MyThread thr2 = new MyThread(cs);
// I get an error message here: No overload for method 'MyThread' takes '1' argument
I am trying to pass the cs string how do I pass multiple messages?
Thread tid1 = new Thread(new ThreadStart(thr1.Thread1(cs)));
Thread tid2 = new Thread(new ThreadStart(thr2.Thread1(cs)));
// I get an error message saying: Method name expected
In the thread.cs file I declare a thread1 function and try to process the cs string that's passed from the serviceexample.cs file:
public void Thread1(string x)
{
for (int i = 0; i < 10; i++)
{
Thread thr = Thread.CurrentThread;
Console.WriteLine(thr.Name + "=" + i);
Thread.Sleep(1);
string[] array = cs.Replace("\\n", "\n").Replace("\0", "").TrimEnd().Split('\n');
// I get an error message at the last line: The type or namespace name 'cs' could not be found (are you missing a using directive or an assembly reference?)
Thank you