473,378 Members | 1,067 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Basic Threading Question

I've a form application that, as one of its functions, gets some data from a
web site.

I wanted to run the process on a thread so that the application doesn't get
tied up whilst the web process is running. However, I want to be able to
time out the thread if its 'completed' event isn't triggered within a set
amount of time.

What the best way to timeout an event? I've tried starting another 'timer'
thread that aborts the web thread when its reaches its timeout value, but it
seems that I must have done it wrong as the whole application slows down,
as it did when I didn't use any threads(!)

I understand that the thread.Join command stops pauses the application until
the thread finishes, so that won't help me.
Nov 30 '05 #1
2 857
I wanted to run the process on a thread so that the application doesn't get
tied up whilst the web process is running. However, I want to be able to
time out the thread if its 'completed' event isn't triggered within a set
amount of time.


How are you getting the website data? If you're using HttpWebRequest
the easiest way would be to set its Timeout property.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 30 '05 #2
I'll give it a try. Thanks
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I wanted to run the process on a thread so that the application doesn't
get
tied up whilst the web process is running. However, I want to be able to
time out the thread if its 'completed' event isn't triggered within a set
amount of time.


How are you getting the website data? If you're using HttpWebRequest
the easiest way would be to set its Timeout property.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Dec 1 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

65
by: Anthony_Barker | last post by:
I have been reading a book about the evolution of the Basic programming language. The author states that Basic - particularly Microsoft's version is full of compromises which crept in along the...
4
by: Richard Spooner | last post by:
Hey, I'm very new to python and am trying to do the following. I may get the jargon wrong at times but hopefully you can see what I'm trying to do... I have created a threaded class which...
7
by: asfwa | last post by:
I'm new to C++ and I have some basic questions. I have written an app that does some network stuff in a worker thread. The thread function requests something from the server, gets it and creates...
5
by: John | last post by:
I have an application that scans files and it takes a while to finish. While my application is running if I open other applications, my main application GUI becomes grey....does not refresh or...
7
by: Anthony Nystrom | last post by:
What is the correct way to stop a thread? abort? sleep? Will it start up again... Just curious... If the thread is enabling a form, if the form is disposed is the thread as well? Thanks, ...
3
by: KC | last post by:
Hey, I'm trying to implement a cancel button in my app (this is after the bulk of the program has been built). To do this I, of course, need to use a thread to run the time consuming method...
4
by: Bob | last post by:
- For cleanup, is it sufficient to set a Thread to Nothing after it's done? - It is OK to pass objects out of the thread? (dumb question maybe but I want to be sure) - What's the best way to...
4
by: DBC User | last post by:
I have a background process which reads a table to see if there are any pending requests. If there are any, then it will start a worker thread (only 10 allowed at a time) and executes a method. In...
2
by: Chris Ashley | last post by:
Hi, I'm overriding WndProc to process some custom messages like so: protected override void WndProc(ref Message m) { if (m.Msg == ImageFileMsg.MSG_IF_NEW_DATA) { ProcessNewDataMessage(m);
19
by: frankiespark | last post by:
Hello all, I was perusing the internet for information on threading when I came across this group. Since there seems to be a lot of good ideas and useful info I thought I'd pose a question. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.