Asynchronous CallBack

M

Marten Van Keer

Hello;



I have a little problem here. I have 2 applications: A and B.



Application B listens to a network stream and uses a AsyncCallback:



Callback = New AsyncCallback(AddressOf OnDataReceived)

m_asynResult = objMySocket.BeginReceive(objMyBytes, 0, objMyBytes.Length,
SocketFlags.None, Callback, Nothing)

When Application B receives data on its network stream it raises an event.



Application A receives the event raised in Application B and starts a
System.Windows.Forms.Timer. This timer should raise a tick event after 10
seconds... But the "Tick" is never triggers ?¿?

It looks like the Timer "tick"-event is absorbed by the Callback in
Application B?



Any idea what the problem is ?




Regards;

MVK
 
C

Cor

Hi Marten,

The most problems with timers is because standard is used the forms.timer.
There are minimal 3 timers.

Have a look at system.timers.timer

I think that will help you because it mostly does.

Cor
 
M

Marten Van Keer

Hi Cor thanks for the information. The event triggers fine now. Thanks!

I have one last question:

Application A can be refreshed manualy and automatic.

Manually by pressing F5

Automatic: When the Timer Tick is raised.

Now the strange thing is that the Manual refresh goes fast and the automatic
refresh goes very slow (repainting screen goes very slow it takes a lot of
time.)
Any idea why the automatic refresh goes slower than the manual refresh ?
(the refresh function is the same in both cases).

Greetz
M.
 
C

Cor

Hi Marten,

Sorry I don't know, but maybe because that timer, I don't like them.

When I can avoid them by using

Do until somethingHappens
threading.thread.sleep(50)
applications.doevents
loop

I do that.

But the timer is in system, so that would be better I think

Success

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top