Click here to Skip to main content
15,898,373 members
Home / Discussions / C#
   

C#

 
QuestionRe: Perhaps only one thread? Pin
RizwanSharp19-Jul-06 11:16
RizwanSharp19-Jul-06 11:16 
GeneralRe: Thread Safety??? Pin
Super Lloyd19-Jul-06 17:22
Super Lloyd19-Jul-06 17:22 
QuestionRe: Thread Safety??? Pin
Dustin Metzgar19-Jul-06 9:13
Dustin Metzgar19-Jul-06 9:13 
AnswerRe: Thread Safety??? Pin
RizwanSharp19-Jul-06 9:52
RizwanSharp19-Jul-06 9:52 
GeneralRe: Thread Safety??? Pin
Dustin Metzgar19-Jul-06 10:16
Dustin Metzgar19-Jul-06 10:16 
GeneralRe: Thread Safety??? Pin
RizwanSharp19-Jul-06 11:15
RizwanSharp19-Jul-06 11:15 
GeneralRe: Thread Safety??? Pin
Dustin Metzgar19-Jul-06 11:25
Dustin Metzgar19-Jul-06 11:25 
GeneralRe: Thread Safety??? Pin
RizwanSharp19-Jul-06 11:35
RizwanSharp19-Jul-06 11:35 
Forget about all the things and focus only on this code:
public void SendMessage(TextMessage messageToSend)<br />
{<br />
try<br />
{<br />
lock (this.dataStream)<br />
{<br />
byte[] serializedBytes = messageToSend.GetBytes(); // Get bytes from the Message object<br />
byte[] encMessageBytes = encryptorDecryptor.Encrypt(serializedBytes); // Encrypt bytes<br />
serializedBytes = null;<br />
int messageSize = encMessageBytes.Length;<br />
byte[] messageSizeBuffer = new byte[this.messageDataLengthBufferSize];<br />
messageSizeBuffer = BitConverter.GetBytes(messageSize);<br />
this.dataStream.Write(messageSizeBuffer, 0, this.messageDataLengthBufferSize); // Send the size of the message<br />
this.dataStream.Write(encMessageBytes, 0, messageSize); // Send the actual message<br />
this.dataStream.Flush();<br />
messageSizeBuffer = null;<br />
encMessageBytes = null;<br />
}<br />
<br />
}<br />
catch<br />
{<br />
}

Now try to follow me:
Code bock 'A' Makes a call SendMessage(textMessage1);
and SendMessage is in the middle of its work and a Code Block 'B' also call this Method SendMessage(textMessage2);
the second call overwrite the textMessage1 with textMessage2D'Oh! | :doh: I think this is the problem May be I'm wrongCry | :(( I dont know what to doSigh | :sigh:
Thanks for your help. If you have something more in mind please help me. I really need this so urgent.
Best Regards,
Rizwan
GeneralRe: Thread Safety??? Pin
Dustin Metzgar19-Jul-06 13:45
Dustin Metzgar19-Jul-06 13:45 
AnswerGot the actual problem!!! Pin
RizwanSharp19-Jul-06 21:43
RizwanSharp19-Jul-06 21:43 
GeneralRe: Got the actual problem!!! Pin
Dustin Metzgar20-Jul-06 5:23
Dustin Metzgar20-Jul-06 5:23 
GeneralSolved ;) Pin
RizwanSharp20-Jul-06 5:33
RizwanSharp20-Jul-06 5:33 
QuestionHow to get some special Windows colors? Pin
NPowDev19-Jul-06 7:25
NPowDev19-Jul-06 7:25 
AnswerRe: How to get some special Windows colors? Pin
Judah Gabriel Himango19-Jul-06 7:29
sponsorJudah Gabriel Himango19-Jul-06 7:29 
Generaland System.Drawing.SystemColors Pin
Ennis Ray Lynch, Jr.19-Jul-06 8:35
Ennis Ray Lynch, Jr.19-Jul-06 8:35 
GeneralRe: How to get some special Windows colors? Pin
NPowDev19-Jul-06 12:06
NPowDev19-Jul-06 12:06 
GeneralRe: How to get some special Windows colors? Pin
Judah Gabriel Himango19-Jul-06 17:14
sponsorJudah Gabriel Himango19-Jul-06 17:14 
GeneralRe: How to get some special Windows colors? [modified] Pin
NPowDev20-Jul-06 1:45
NPowDev20-Jul-06 1:45 
GeneralRe: How to get some special Windows colors? Pin
Judah Gabriel Himango20-Jul-06 4:36
sponsorJudah Gabriel Himango20-Jul-06 4:36 
Questionerror Pin
TAREQ F ABUZUHRI19-Jul-06 7:04
TAREQ F ABUZUHRI19-Jul-06 7:04 
AnswerRe: error Pin
Judah Gabriel Himango19-Jul-06 7:12
sponsorJudah Gabriel Himango19-Jul-06 7:12 
QuestionAdd attributes to XML doc [modified] Pin
VK-Cadec19-Jul-06 6:47
VK-Cadec19-Jul-06 6:47 
AnswerRe: Add attributes to XML doc Pin
stancrm19-Jul-06 7:21
stancrm19-Jul-06 7:21 
GeneralRe: Add attributes to XML doc Pin
VK-Cadec19-Jul-06 7:26
VK-Cadec19-Jul-06 7:26 
GeneralRe: Add attributes to XML doc Pin
Rob Graham19-Jul-06 10:45
Rob Graham19-Jul-06 10:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.