C
Claire
Visual Studio 2003
I have a thread running a small timeout. Rather than defining my own
delegate I decided to be lazy and use a standard EventHandler delegate
When OnReadMessageTimeout is called, "sender" appears to points to the form
that started the thread rather than Thread.CurrentThread.Name.
What is going wrong please?
_ReadTimeoutThread = new Thread(new ThreadStart(OnReadMessageLoop));
_ReadTimeoutThread.IsBackground = true;
_ReadTimeoutThread.Name = "_ReadTimeoutThread";
_ReadTimeoutThread.Start();
private void OnReadMessageLoop()
{
Thread.Sleep(1000);
Invoke(new EventHandler(OnReadMessageTimeout), new
object[]{Thread.CurrentThread.Name ,null});
}
private void OnReadMessageTimeout(object sender, System.EventArgs f)
{
!!! sender is owning form and not the string "_ReadTimeoutThread"
string Name = (string)sender;
if (Name != "")
{
foobar
I have a thread running a small timeout. Rather than defining my own
delegate I decided to be lazy and use a standard EventHandler delegate
When OnReadMessageTimeout is called, "sender" appears to points to the form
that started the thread rather than Thread.CurrentThread.Name.
What is going wrong please?
_ReadTimeoutThread = new Thread(new ThreadStart(OnReadMessageLoop));
_ReadTimeoutThread.IsBackground = true;
_ReadTimeoutThread.Name = "_ReadTimeoutThread";
_ReadTimeoutThread.Start();
private void OnReadMessageLoop()
{
Thread.Sleep(1000);
Invoke(new EventHandler(OnReadMessageTimeout), new
object[]{Thread.CurrentThread.Name ,null});
}
private void OnReadMessageTimeout(object sender, System.EventArgs f)
{
!!! sender is owning form and not the string "_ReadTimeoutThread"
string Name = (string)sender;
if (Name != "")
{
foobar