I want to broadcast live data from one server to multiple clients using There is a problem with this implementation, which changes to Also, I think that there should be some easy solution to my original problem and that the idea of using a byte [] line for a live broadcast is not the best. I would appreciate any point in some better direction. I can not help but I think there is some information missing here. In the given code, the buffer monitor is never started. If this is not done in some code that you have not included, then I hope the lock call is unsuccessful. You are saying that readyToSend is never set to True by the given code, it can suggest that the client connected method is never called , Or [...] is throwing / returning before the line of method. Can you say that the customer is connecting? Understand this, monitor. Waiting (locked object is designed to handle) Only if Monitor Pulsal is executed, then returning is being returned in waiting condition after thread A. Are you sure that this is the sequence of events which is happening? If the pulse occurs before the wait, the thread will not wake up. The stupid question is, but are you sure that you are calling it on the same instance of the object? So the line is populated properly? socket
, I am in concurrency issues with my current implementation.
public class connection {Private unmanaged bull preparation endand; Private queue & lt; Byte [] & gt; Q; Private object buffer monitor; Public connection [// All things start and connect etc.] [...] // Some other functions which are irrelevant to this problem, called Private Zero Client Connect (Socket ASCINK Avenant ARGS) {// Thread A Is [ready] ToSend = true; WaitingForResponse (args); } Private Zero WaitingForResponse (SocketAsyncEventArgs) {// if called by Thread A (q.Count == 0) {Lock (buffer monitor) {Monitor.Wait (buffer monitor); }} If (q.Count! = 0) {byte [] data; Lock (q) {data = q.Dequeue (); } Args.Setbuffer (0, data lang); Args.ConnectSocket.SendAsync (args); // will send all bytes and later will remember the waiting force response I}} Internal Zero SendIf Connect (Byte [] data) {// Called by Thread B (if readyToSend) {lock (Q) {q.Enqueue ( Data); } Lock (buffer monitor) {Monitor. Pulsar (buffer monitor); }}}}
readyToSend when a client joins does not appear in the second thread - the second problem That is, if you put a breakpoint in the
SendIfconnected function and manually consider the value to be correct, then
monitor. Waiting () Monitor will never come though. Pulse all execute.
Comments
Post a Comment