Re: Still the same: CAsyncSocket::Receive and CAsyncSocket's threading
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Tue, 09 May 2006 13:19:34 -0400
First off, the Sleep(10) is pretty weird. In fact, you can be reasonably confident that
if your threaded code requires a Sleep() to operate properly, you can assume that your
threading implementation is flawed and *must* be recoded to be reasonable.
You *must* use a UI thread to implement the thread. I don't even recognize the syntax you
show below, so I can't tell what you are trying to express here. A class? A function? You
have not shown the call you use to create the thread, but it really has to be a call that
creates a UI thread. The fact that it works when you have a MessageBox proves that you
are not using a UI thread.
joe
On Tue, 09 May 2006 09:57:24 +0200, MiSo <mi_so@xxxxx> wrote:
Hello,Joseph M. Newcomer [MVP]
I red all messages, about CAsynchSocket and threading and also Mr Newcomer
mvp_tips. And still my problem persist.
Shortly I've problem with client socket.
My dll library implements protocol to some server. I'm using CAsyncSocket.
Dll must be using from dot.Net framework and when I use it simple by calling
functions from dll all works fine.
But when I create thread and thees all functions are called from thread function
OnReceive is not fired.
myThreadFunction {
CreateObjectsDll();
InitSocketsDll();
ConnectToServerDll();
while ( canrun ){
Thread.Sleep(10);
...;
}
}
In my case ConnectToServerDll - should cause that server sends data to client.
In example above I receive no data but when I add MessageBox.ShowModal(); ->
myThreadFunction {
CreateObjectsDll();
InitSocketsDll();
ConnectToServerDll();
MessageBox.ShowModal();
while ( canrun ){
Thread.Sleep(10);
...;
}
}
I receive data.
Can someone explain this behavior?
I TRACE all functions and I print ThreadID. I see all my operations on dll are
in the same thread. Then I think that I don't need to deattach and attach SOCKET.
Mirek Sobczak
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
--
NewsGuy.Com 30Gb $9.95 Carry Forward and On Demand Bandwidth
.
- Follow-Ups:
- References:
- Prev by Date: Re: Crash in CAsyncSocket::Create
- Next by Date: Re: Traversing shallow CTreeCtrl
- Previous by thread: Re: Still the same: CAsyncSocket::Receive and CAsyncSocket's threading
- Next by thread: Re: Still the same: CAsyncSocket::Receive and CAsyncSocket's threading
- Index(es):