Can someone explain this...
VS2010 .net 3.5
Code:
private void ReadDaqThreadProc()
{
dThreadCallback tcb = new dThreadCallback(ReadDaq);
while (flags.daqEnabled)
{
try
{
this.Invoke(tcb, new Object[] { }); }
catch (Exception e)
{
}
Thread.Sleep(50);
}
}
This snippet is part of a multithreaded app. "tcb" is a delegate, ReadDaq is a function in the MainForm code, and ReadDaqThreadProc is in its own thread. I know what the code does but I dont know how. I'd like to understand how this works. The line in question is the invoke line. Is 'new Object[] {}' an argument list for ReadDaq?
Re: Can someone explain this...
The Invoke method takes as it's second parameter an array of objects containing the values for the method parameters (parameters for the method being invoked). If the method being invoked needs no parameters, you pass an empty object array. The syntax for creating an empty array of objects is:
new object[] { }