473,378 Members | 1,580 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.

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 1245
<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.com>
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.2005APR.1033/cpguide/html/cpconthreadsthreading.htm
ms-help://MS.MSDNQTR.2005APR.1033/cpref/html/frlrfSystemThreadingThreadClassTopic.htm
ms-help://MS.MSDNQTR.2005APR.1033/cpguide/html/cpconCollectionsSynchronizationThreadSafety.htm
ms-help://MS.MSDNQTR.2005APR.1033/cpguide/html/cpconThreadPooling.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
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...
8
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...
13
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...
8
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...
10
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...
2
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...
2
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...
7
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...
0
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...
126
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:...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.