I have a program which is constantly reading from a stream and what I'm
wanting to do is, if the stream hasn't sent anything after a certain amount
of time then do something. I've tried doing this like this...
while(!done)
{
idleTimer.Start();
response = streamReader.ReadLine();
idleTimer.Stop();
....
The interval on the Timer is set to 10000 (10 seconds) but I've hung
response = streamReader.ReadLine() for five minutes and it still doesn't run
the Timer's Tick event. The interesting thing though, is if I do this...
idleTimer.Start();
MessageBox.Show("Testing...");
response = streamReader.ReadLine();
idleTimer.Stop();
....and then don't press the button on the message box, after 10 seconds the
Tick event is fired. So why not after 10 seconds of waiting for a response
from the stream? I've even tried sticking the timer stuff in it's own thread
but I get the same problem.
Please help,
Darrell 3 2120
My guess is that the StreamReader.ReadLine method hangs the current
thread, which prevents it from pumping messages. MessageBox.Show keeps
pumping messages while the message box is displayed, and that lets the
timer messages be handled.
You could perhaps put the StreamReader code in a worker thread, keep the
timer on the ui thread, and when the timer fires check if anything has
been read.
Regards,
Joakim
redneon wrote: I have a program which is constantly reading from a stream and what I'm wanting to do is, if the stream hasn't sent anything after a certain amount of time then do something. I've tried doing this like this...
while(!done) { idleTimer.Start(); response = streamReader.ReadLine(); idleTimer.Stop(); ...
The interval on the Timer is set to 10000 (10 seconds) but I've hung response = streamReader.ReadLine() for five minutes and it still doesn't run the Timer's Tick event. The interesting thing though, is if I do this...
idleTimer.Start(); MessageBox.Show("Testing..."); response = streamReader.ReadLine(); idleTimer.Stop();
...and then don't press the button on the message box, after 10 seconds the Tick event is fired. So why not after 10 seconds of waiting for a response from the stream? I've even tried sticking the timer stuff in it's own thread but I get the same problem.
Please help,
Darrell
I've tried putting the timer stuff in a new thread but I still get the same
problem. The method with the reader in is a thread off the UI in itself
already.
Darrell
"Joakim Karlsson" wrote: My guess is that the StreamReader.ReadLine method hangs the current thread, which prevents it from pumping messages. MessageBox.Show keeps pumping messages while the message box is displayed, and that lets the timer messages be handled.
You could perhaps put the StreamReader code in a worker thread, keep the timer on the ui thread, and when the timer fires check if anything has been read.
Regards, Joakim
redneon wrote: I have a program which is constantly reading from a stream and what I'm wanting to do is, if the stream hasn't sent anything after a certain amount of time then do something. I've tried doing this like this...
while(!done) { idleTimer.Start(); response = streamReader.ReadLine(); idleTimer.Stop(); ...
The interval on the Timer is set to 10000 (10 seconds) but I've hung response = streamReader.ReadLine() for five minutes and it still doesn't run the Timer's Tick event. The interesting thing though, is if I do this...
idleTimer.Start(); MessageBox.Show("Testing..."); response = streamReader.ReadLine(); idleTimer.Stop();
...and then don't press the button on the message box, after 10 seconds the Tick event is fired. So why not after 10 seconds of waiting for a response from the stream? I've even tried sticking the timer stuff in it's own thread but I get the same problem.
Please help,
Darrell
redneon... I just finished a sample project that launches I/O threads
and calls WaitForThreadExit(waitForThreadTime). Basically, each I/O
thread callsback when done. The worker thread sleeps in a loop checking
to see if the I/O thread has returned. If the waitForThreadTime is
exceeded the worker thread exits the loop. http://www.geocities.com/jeff_louie/call_console.htm
Regards,
Jeff I've tried putting the timer stuff in a new thread but I still get the
same problem.<
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dhilip Kumar |
last post by:
Hi all,
I have developed a windows service using the windows service project
template in VS.NET. I have used three controls in the service, a timer,
performance counter and a message queue...
|
by: Jim Hammond |
last post by:
The following code tries to excute a function 10 seconds after Page_Load by using a Timer, but the callback never gets called.
private void Page_Load(object sender, System.EventArgs e)
{
...
|
by: Antti Laakso |
last post by:
Hi
i have function like above
Public Sub halytystutkinta()
Dim ds As New DataSet
ds = dl2.HaeHalytys()
Dim onkohal As Int16
onkohal = ds.Tables(0).Rows(0).Item("onkohalytys")
halid =...
|
by: Martin Hill |
last post by:
Hi there,
How can I find the components added to web form from my custom web
control?
Suppose I added a Timer component (with name "timer1") onto the web
form, from my user web
control, how...
|
by: Noggin The Nog |
last post by:
Hi all, I've been trying to get HttpWebResponse to work, but whenever I try I
get "The operation has timed-out". I'm simply trying to send an HTTP request
querystring to a remote website and read...
|
by: Crirus |
last post by:
Hi!
I havea control that display messages...
I added a timer to it
Every time a noew mesaage should be displayed I do the following:
Private sub ShowMsg(message as string)
Me.lblStatus.Text...
|
by: les |
last post by:
I'm trying to http post xml data to a remote server and I get this
error:
BC30518: Overload resolution failed because no accessible 'GetBytes'
can be called with these arguments:
Line 20: Dim...
|
by: Lemune |
last post by:
Hello everyone.
I'm using vb 2005. I'm creating program that run as service on windows.
And in my program I need to use timer, so I'm using timer object from
component. I try my source code on...
|
by: Peter Oliphant |
last post by:
Note that although this involves SAPI, it is more a question about Timers
and event handlers.
I wrote a Speech Recognize handler (SAPI), and put some code in it to enable
a Timer. It would not...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |