Click here to Skip to main content
15,900,258 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to remove a character from a string - help required Pin
Coding C#20-Aug-06 23:16
Coding C#20-Aug-06 23:16 
GeneralRe: How to remove a character from a string - help required Pin
James1984198420-Aug-06 6:00
James1984198420-Aug-06 6:00 
GeneralRe: How to remove a character from a string - help required Pin
Colin Angus Mackay20-Aug-06 6:45
Colin Angus Mackay20-Aug-06 6:45 
GeneralRe: How to remove a character from a string - help required Pin
Nader Elshehabi20-Aug-06 10:06
Nader Elshehabi20-Aug-06 10:06 
QuestionThreading issue Pin
theonewithtom20-Aug-06 4:26
theonewithtom20-Aug-06 4:26 
AnswerRe: Threading issue Pin
Nader Elshehabi20-Aug-06 5:03
Nader Elshehabi20-Aug-06 5:03 
GeneralRe: Threading issue Pin
theonewithtom20-Aug-06 5:46
theonewithtom20-Aug-06 5:46 
GeneralRe: Threading issue [modified] Pin
Nader Elshehabi20-Aug-06 10:12
Nader Elshehabi20-Aug-06 10:12 
Hello

Of course you can using a single thread. Actually what happens behind the scene is that the asynchronous call makes an anonymous worker thread for you that will carry the action. When that thead receives anything it will call the Callback method that you will provide as a delegate.

Take a look t this code, copied from MSDN:

IPHostEntry lipa = Dns.Resolve("host.contoso.com");
IPEndPoint lep = new IPEndPoint(lipa.AddressList[0], 11000);

   Socket s = new Socket(lep.Address.AddressFamily,
                                  SocketType.Stream,
                                     ProtocolType.Tcp);
   try{
        s.Bind(lep);
        s.Listen(1000);

        while(true){
             allDone.Reset();

             Console.WriteLine("Waiting for a connection...");
             s.BeginAccept(new AsyncCallback(Async_Send_Receive.Listen_Callback), s);

             allDone.WaitOne();
        }
   }
   catch (Exception e){
        Console.WriteLine(e.ToString());
   }



All you have to do is to provide the callback method.

RegardsRose | [Rose]


-- modified at 16:16 Sunday 20th August, 2006

Sorry, I just noticed you said "async" not "sync". What's exactly your problem with the above approach??

RegardsRose | [Rose]
GeneralRe: Threading issue Pin
theonewithtom20-Aug-06 23:55
theonewithtom20-Aug-06 23:55 
GeneralRe: Threading issue Pin
Nader Elshehabi21-Aug-06 1:42
Nader Elshehabi21-Aug-06 1:42 
QuestionRe: Threading issue Pin
theonewithtom21-Aug-06 4:27
theonewithtom21-Aug-06 4:27 
AnswerRe: Threading issue Pin
Nader Elshehabi21-Aug-06 5:15
Nader Elshehabi21-Aug-06 5:15 
AnswerRe: Threading issue Pin
S. Senthil Kumar20-Aug-06 19:08
S. Senthil Kumar20-Aug-06 19:08 
AnswerRe: Threading issue Pin
Andrei Ungureanu20-Aug-06 20:28
Andrei Ungureanu20-Aug-06 20:28 
QuestionInstall !!? Pin
MHASSANF20-Aug-06 2:48
MHASSANF20-Aug-06 2:48 
QuestionRe: Install !!? Pin
Anthony Mushrow20-Aug-06 3:05
professionalAnthony Mushrow20-Aug-06 3:05 
QuestionRe: Install !!? [modified] Pin
MHASSANF20-Aug-06 3:10
MHASSANF20-Aug-06 3:10 
AnswerRe: Install !!? Pin
Vitaliy Tsvayer20-Aug-06 3:32
Vitaliy Tsvayer20-Aug-06 3:32 
GeneralRe: Install !!? Pin
thunderbirdje20-Aug-06 10:54
thunderbirdje20-Aug-06 10:54 
AnswerRe: Install !!? Pin
Nader Elshehabi20-Aug-06 4:50
Nader Elshehabi20-Aug-06 4:50 
GeneralRe: Install !!? Pin
Anthony Mushrow20-Aug-06 10:59
professionalAnthony Mushrow20-Aug-06 10:59 
QuestionHaving a strange problem... Pin
Anthony Mushrow20-Aug-06 2:42
professionalAnthony Mushrow20-Aug-06 2:42 
AnswerRe: Having a strange problem... Pin
leppie20-Aug-06 3:12
leppie20-Aug-06 3:12 
GeneralRe: Having a strange problem... Pin
Anthony Mushrow20-Aug-06 11:02
professionalAnthony Mushrow20-Aug-06 11:02 
GeneralRe: Having a strange problem... [modified] Pin
Anthony Mushrow20-Aug-06 11:08
professionalAnthony Mushrow20-Aug-06 11:08 

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.