Timers and Threads

  • Thread starter Anders Eriksson
  • Start date
A

Anders Eriksson

Hello,

I have a class in which I use System.Threading.Timer. The callback function
should send a message using TCPClient. Since the Callback function is in an
another thread this doesn't work!

How do I Invoke a function in the class thread from the callback function?

The Class is not a Form class!

// Anders
--
English is not my first language
so any error, insults or strangeness
has happend during the translation.
Please correct my English so that I
may become better at it!
 
P

Peter Duniho

Anders said:
Hello,

I have a class in which I use System.Threading.Timer. The callback
function should send a message using TCPClient. Since the Callback
function is in an another thread this doesn't work!

You need to be more specific. Neither TcpClient nor Socket have the
kind of thread affinity that System.Windows.Forms.Control has which
would require invoking a method on a specific thread.

What "doesn't work" about using TcpClient in the callback for the Timer?

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top