473,748 Members | 2,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Threading help.

Hi all,
i am having c# application.
I have bunch of URL's which i want to validate.
that means i want to check whether those url's are valid or not.
When i start processing url's one by on synchronysly its taking lots of
time.
So what i want is to split above task.
I want to use threading in this case to make process faster.
I want to created threads which are processing say 5 urls at a time.
Like that i want to create some threads which are validating url's.
is it correct way to make process faster.

And one more question.
Can i change thread procedure of thread without creating new thread.
Like say suppose i have one thread for which i have assigned some
thread procedure.
After that thread procedure is over i want to use same thread object to
reassign some other thread procedure.
Can i do it.
Any help will be appreciated.

Nov 17 '05 #1
2 1284
<tr************ **@yahoo.com> wrote:
Hi all,
i am having c# application.
I have bunch of URL's which i want to validate.
that means i want to check whether those url's are valid or not.
When i start processing url's one by on synchronysly its taking lots of
time.
So what i want is to split above task.
I want to use threading in this case to make process faster.
I want to created threads which are processing say 5 urls at a time.
Like that i want to create some threads which are validating url's.
is it correct way to make process faster.
Well, an alternative would be to use asynchronous calls with
WebRequest. Using new threads would work though. Bear in mind that if
you have lots of URLs to the same host, .NET will (by default) limit
how many simultaneous connections you can make to that machine.
And one more question.
Can i change thread procedure of thread without creating new thread.
Like say suppose i have one thread for which i have assigned some
thread procedure.
After that thread procedure is over i want to use same thread object to
reassign some other thread procedure.
Can i do it.
Any help will be appreciated.


That's the job of a thread pool. I don't recommend using the system
thread pool as it can lead to deadlock very easily. See
http://www.pobox.com/~skeet/csharp/miscutil for a free custom thread
pool.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Creating a thread involves the following steps :

1) Creating a ThreadStart delegate to specify the code that you want to
run as a thread. Keep in mind that this does not support parameters, so
if you want to pass some data to your thread you have to create a class
that will hold the method and the parameters.

2) Creating a Thread class with the ThreadStart that you created above
as a parameter.

Apparently the use of threads in your example is pretty normal as long
as you pay attention to things like synchronization issues and objects
locking.

Now... for your second question... no you cant.

Refs :
ms-help://MS.MSDNQTR.2005 APR.1033/cpguide/html/cpconthreadsthr eading.htm
ms-help://MS.MSDNQTR.2005 APR.1033/cpref/html/frlrfSystemThre adingThreadClas sTopic.htm
ms-help://MS.MSDNQTR.2005 APR.1033/cpguide/html/cpconCollection sSynchronizatio nThreadSafety.h tm
ms-help://MS.MSDNQTR.2005 APR.1033/cpguide/html/cpconThreadPool ing.htm

Have a nice day ...

Nov 17 '05 #3

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

Similar topics

65
6748
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 language's 30+ year evolution. What to you think python largest compromises are? The three that come to my mind are significant whitespace, dynamic typing, and that it is interpreted - not compiled. These three put python under fire and cause...
8
8212
by: Z D | last post by:
Hello, I'm having a strange problem that is probably due to my lack of understanding of how threading & COM Interop works in a WinForms.NET application. Here's the situation: I have a 3rd party COM component that takes about 5 seconds to run one of its functions (Network IO bound call). Since I dont want my GUI to freeze
13
371
by: RCS | last post by:
I have a UI that needs a couple of threads to do some significant processing on a couple of different forms - and while it's at it, update the UI (set textboxes, fill in listviews). I created a base class for the worker class, and made up some functions/delegates to handle the invoke stuff for the UI and that was fine for a prototype. I rewrote this chunk, broke things out into different classes - but the threading is still the same - and...
8
13495
by: Yatharth | last post by:
Hi, I m new to threading and i have successfully runed threading but i could display value on my web page ,but its working in code behind when i see it through debugger,plzzzzzzz help me here is the code below: i just wana display the simple array value stored in my array variable in my textbox thats it.
10
1611
by: MikeScullion | last post by:
I have set up this thread so my program doesn't hang while I call a cpu intensive bit of code: System.Threading.ThreadStart ThreadEncoderStart = new System.Threading.ThreadStart(myEncoder.EncodeFromConsole); System.Threading.Thread Thread_myEncoder = new System.Threading.Thread(ThreadEncoderStart); Thread_myEncoder.Name = "myEncoder"; Thread_myEncoder.Priority = System.Threading.ThreadPriority.BelowNormal;
2
2246
by: Vjay77 | last post by:
In this code: Private Sub downloadBtn_Click(ByVal sender As Object, ByVal e As System.EventArgs) If Not (Me.downloadUrlTextBox.Text = "") Then Me.outputGroupBox.Enabled = True Me.bytesDownloadedTextBox.Text = "" Me.totalBytesTextBox.Text = ""
2
1418
by: hecklar | last post by:
This is my first time posting here, so i apologize if i'm posting in the wrong subgroup or whatever, but here goes... I’m having a problem with threading and events (permissions?) in a VB.net Windows application (background service). I’m trying to write an application that processes files, launching a new thread for each file that is dropped into a certain folder. Now, the application works like a charm on my Win2000 machine, but...
7
2377
by: Mike P | last post by:
I am trying to write my first program using threading..basically I am moving messages from an Outlook inbox and want to show the user where the process is up to without having to wait until it has finished. I am trying to follow this example : http://www.codeproject.com/cs/miscctrl/progressdialog.asp But although the messages still get moved, the progress window never does anything. Here is my code in full, if anybody who knows...
0
1875
ammoos
by: ammoos | last post by:
hi friends pls help me.. i got an assignment which i feel very difficult to me.. i dont have more knowledge about multi-threading in .net... the assignment details is below.... pls help me... i have to submit this assignment today evening... please....... Windows Application to demonstrate the use of Multi-Threading with Synchronous & Asynchronous Threading. Requirements 1) A form with a) a button to initialize threads ...
126
6725
by: Dann Corbit | last post by:
Rather than create a new way of doing things: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2497.html why not just pick up ACE into the existing standard: http://www.cse.wustl.edu/~schmidt/ACE.html the same way that the STL (and subsequently BOOST) have been subsumed? Since it already runs on zillions of platforms, they have obviously worked most of the kinks out of the generalized threading and processes idea (along with many...
0
8996
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9386
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6799
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6078
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2217
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.