C#: Cross-Thread Problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Iridium
    New Member
    • Nov 2007
    • 6

    C#: Cross-Thread Problem

    Greetings,

    First I'd like to say that this is a very nice forum and it already helped me alot with some other projects. But now to the problem:

    I wrote a server that is based on the code found here . This server allows me to handle multible clients/connections at the same time.

    Now I need to add an event (for example a key is pressed), which then sends a specific message to all clients that are actually connected. The problem here is that I dont know how to do that, since there are multible threads running the same code but with a different client.

    Since the control that sends the event is in the main thread, it has something to do with cross-thread operations.

    Does anyone have an idea?

    Thanks in advance
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Is this event based around a time, admin initiating or user?

    Comment

    • Iridium
      New Member
      • Nov 2007
      • 6

      #3
      Originally posted by kenobewan
      Is this event based around a time, admin initiating or user?
      No, that event is not around a time, its coming from an external source and then needs to be transmitted to the clients. It would be also nice if I could "forward" the message coming from the event to the clients, but thats a different task. So just basically get the server to send a message to the clients as soon the event occurs.

      Comment

      • krishnabhargav
        New Member
        • Feb 2008
        • 24

        #4
        Originally posted by Iridium
        Greetings,

        First I'd like to say that this is a very nice forum and it already helped me alot with some other projects. But now to the problem:

        I wrote a server that is based on the code found here . This server allows me to handle multible clients/connections at the same time.

        Now I need to add an event (for example a key is pressed), which then sends a specific message to all clients that are actually connected. The problem here is that I dont know how to do that, since there are multible threads running the same code but with a different client.

        Since the control that sends the event is in the main thread, it has something to do with cross-thread operations.

        Does anyone have an idea?

        Thanks in advance
        Few years back when i was learning .net 1.1, we used to do Remoting for such scenarios...my memories are all dried up but i thought if u think on these lines you would be able to solve it.

        Comment

        • Iridium
          New Member
          • Nov 2007
          • 6

          #5
          Originally posted by krishnabhargav[..
          Remoting for such scenarios.[..]
          Well, Remoting sounds interessting, but the connection is also used for other things, so I will use TCP connections.
          Noone has an idea how I could solve that?

          Comment

          • Iridium
            New Member
            • Nov 2007
            • 6

            #6
            Noone has a good idea? I still have the same problem and I cant find a solution.

            Comment

            Working...