Click here to Skip to main content
15,922,015 members
Home / Discussions / C#
   

C#

 
AnswerRe: cant convert c# type string to c++ type char* Pin
Marc Clifton25-Jan-07 4:32
mvaMarc Clifton25-Jan-07 4:32 
Questiondatabase watcher ... need suggestions !! Pin
eng_Hosam Kamel25-Jan-07 1:51
eng_Hosam Kamel25-Jan-07 1:51 
AnswerRe: database watcher ... need suggestions !! Pin
Pete O'Hanlon25-Jan-07 2:21
mvePete O'Hanlon25-Jan-07 2:21 
AnswerRe: database watcher ... need suggestions !! Pin
Sylvester george25-Jan-07 2:23
Sylvester george25-Jan-07 2:23 
Questioncheck whether word file is open or not Pin
praveen pandey25-Jan-07 1:45
praveen pandey25-Jan-07 1:45 
AnswerRe: check whether word file is open or not Pin
ednrgc25-Jan-07 5:49
ednrgc25-Jan-07 5:49 
QuestionOpen word document Pin
zt.Prog25-Jan-07 1:36
zt.Prog25-Jan-07 1:36 
QuestionNetwork programming problem Pin
Antony Lee25-Jan-07 1:26
Antony Lee25-Jan-07 1:26 
Hi All

Does anyone know the behaviour of the TcpClient.GetStream().Write()
on .NET CF 2.0 or any wrong in my code ?

I wrote the code listed at the end and found that even the network cable
was disconnected from my server, the TcpClient.GetStream().Write()
was not blocked. That was the code continued to run the line Console.WriteLine("Breakpoint 2");

When the program started, the following output produced:
Sending: 0000000001
Breakpoint 1
Breakpoint 2
Sending: 0000000002
Breakpoint 1
Breakpoint 2
< network cable disconnected >
Sending: 0000000003
Breakpoint 1
Breakpoint 2
Sending: 0000000004
Breakpoint 1
Breakpoint 2
< network cable re-connected >
Sending: 0000000005
Breakpoint 1
Net Error
Sending: 0000000005
Breakpoint 1
Breakpoint 2


The following is my code snippet
private void Connect()
{
}

private void SendMessageThread()
{
    String message = String.Empty;
    this.IsRunning = true;

    while (this.IsRunning)
    {
        try
        {
            if ((this.IsRunning) && (!IsConnected)) Connect();
            if ((this.IsRunning) && (IsConnected))
            {
                if (message == String.Empty)
                {
                    message = DequeueManagerMessage();
                }

                if (message != String.Empty)
                {
                    lock (this)
                    {
                        Console.WriteLine("Sending: {0}", message);
                        Byte[] data = 
                                System.Text.Encoding.ASCII.GetBytes(
                                           message.ToCharArray());
                        Console.WriteLine("Breakpoint 1");
                        tcpClient.GetStream().Write(data, 0, data.Length);
                        Console.WriteLine("Breakpoint 2");
                        message = String.Empty;
                    }
                }                        
            }
        }
        catch
        {
            Console.WriteLine("Net Error");
            Disconnect();
        }
    }

    this.IsRunning = false;
}


Antony
AnswerRe: Network programming problem Pin
Antony Lee25-Jan-07 17:03
Antony Lee25-Jan-07 17:03 
QuestionCreation of Connectors between Elements of a Form Without using Graphics Pin
UdayDenduluri25-Jan-07 1:13
UdayDenduluri25-Jan-07 1:13 
AnswerRe: Creation of Connectors between Elements of a Form Without using Graphics Pin
V.25-Jan-07 1:26
professionalV.25-Jan-07 1:26 
QuestionNaming conventions for Variables in C# Pin
nasambur25-Jan-07 0:59
nasambur25-Jan-07 0:59 
AnswerRe: Naming conventions for Variables in C# Pin
Pete O'Hanlon25-Jan-07 1:10
mvePete O'Hanlon25-Jan-07 1:10 
AnswerRe: Naming conventions for Variables in C# Pin
Stefan Troschuetz25-Jan-07 1:11
Stefan Troschuetz25-Jan-07 1:11 
AnswerRe: Naming conventions for Variables in C# Pin
V.25-Jan-07 1:24
professionalV.25-Jan-07 1:24 
QuestionCreating Oracle Connection Pin
Mr.Sam25-Jan-07 0:59
Mr.Sam25-Jan-07 0:59 
AnswerRe: Creating Oracle Connection Pin
V.25-Jan-07 1:24
professionalV.25-Jan-07 1:24 
QuestionUsing remote folders. [modified] Pin
jarellan25-Jan-07 0:20
jarellan25-Jan-07 0:20 
QuestionC# Pin
saurabh_bpl425-Jan-07 0:06
saurabh_bpl425-Jan-07 0:06 
AnswerRe: C# Pin
Colin Angus Mackay25-Jan-07 0:10
Colin Angus Mackay25-Jan-07 0:10 
GeneralRe: C# Pin
dataminers25-Jan-07 0:23
dataminers25-Jan-07 0:23 
GeneralRe: C# Pin
quiteSmart25-Jan-07 0:43
quiteSmart25-Jan-07 0:43 
GeneralRe: C# Pin
Pete O'Hanlon25-Jan-07 1:06
mvePete O'Hanlon25-Jan-07 1:06 
AnswerRe: C# Pin
Ed.Poore25-Jan-07 1:14
Ed.Poore25-Jan-07 1:14 
AnswerRe: C# Pin
ednrgc25-Jan-07 5:52
ednrgc25-Jan-07 5:52 

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.