473,405 Members | 2,354 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,405 software developers and data experts.

Threading in C#

Hi,
I have a page that calls a sql procedure and it runs for 20 - 40 min. I
use usual threading for this page.

<code>Thread objthread = new Thread(new ThreadStart(ticketingThread));
objthread.Start();</code>

As i dont know when it will end. i never abort the thread. what happens
is when user uses the page for 1 week, the page starts hanging. I dont
know what happens. When i tried debugging it works fine.

I also saw creating thread in threadpools

<code>ThreadPool.QueueUserWorkItem(new
WaitCallback(ticketingThread));</code>

Please advise which one I have to follow and what is the difference
between the two.

Thanks
Venkat

Jun 12 '06 #1
6 3081
It would be pretty difficult to provide any kind of help for this
problem, as there is no source-code or a more specific indication about
the threading code, application, database.

It could be from a threading race condition to a database lock to
resources exhaustion.

Now, for your second question, by using ThreadPool you pick a thread
from the ThreadPool (whenever and if it's available) and you ensure
that the thread will be returned to the pool and you won't have an
arbitary number of thread running.

What you will follow is a matter of requirements.

Regards,
Tasos

venkat wrote:
Hi,
I have a page that calls a sql procedure and it runs for 20 - 40 min. I
use usual threading for this page.

<code>Thread objthread = new Thread(new ThreadStart(ticketingThread));
objthread.Start();</code>

As i dont know when it will end. i never abort the thread. what happens
is when user uses the page for 1 week, the page starts hanging. I dont
know what happens. When i tried debugging it works fine.

I also saw creating thread in threadpools

<code>ThreadPool.QueueUserWorkItem(new
WaitCallback(ticketingThread));</code>

Please advise which one I have to follow and what is the difference
between the two.

Thanks
Venkat


Jun 12 '06 #2
Thanks Tasos,
The scenario is I have a button that initiate the ticket processing.
(You can call it like a batch process). It calls a procedure and it
internally calls number of procedures. If the number of items to be
processed is less, then it will take 10-25 min, and max is 40 min. This
is a maintenence work. The existing code works very well but. on due
course the particular page starts hanging. there is no spl code in
that. It has two drop down with two items in it. on slections of those
items user has to click initiate process button. If I restart www
service it starts working fine. that is why I came in to conslusion the
problem is with the threads. (is this correct).

Thanks
Venkat

Tasos Vogiatzoglou wrote:
It would be pretty difficult to provide any kind of help for this
problem, as there is no source-code or a more specific indication about
the threading code, application, database.

It could be from a threading race condition to a database lock to
resources exhaustion.

Now, for your second question, by using ThreadPool you pick a thread
from the ThreadPool (whenever and if it's available) and you ensure
that the thread will be returned to the pool and you won't have an
arbitary number of thread running.

What you will follow is a matter of requirements.

Regards,
Tasos

venkat wrote:
Hi,
I have a page that calls a sql procedure and it runs for 20 - 40 min. I
use usual threading for this page.

<code>Thread objthread = new Thread(new ThreadStart(ticketingThread));
objthread.Start();</code>

As i dont know when it will end. i never abort the thread. what happens
is when user uses the page for 1 week, the page starts hanging. I dont
know what happens. When i tried debugging it works fine.

I also saw creating thread in threadpools

<code>ThreadPool.QueueUserWorkItem(new
WaitCallback(ticketingThread));</code>

Please advise which one I have to follow and what is the difference
between the two.

Thanks
Venkat


Jun 12 '06 #3
Is it necessary for you to use threading in webform?

chanmm

"venkat" <ve**********@gmail.com> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Thanks Tasos,
The scenario is I have a button that initiate the ticket processing.
(You can call it like a batch process). It calls a procedure and it
internally calls number of procedures. If the number of items to be
processed is less, then it will take 10-25 min, and max is 40 min. This
is a maintenence work. The existing code works very well but. on due
course the particular page starts hanging. there is no spl code in
that. It has two drop down with two items in it. on slections of those
items user has to click initiate process button. If I restart www
service it starts working fine. that is why I came in to conslusion the
problem is with the threads. (is this correct).

Thanks
Venkat

Tasos Vogiatzoglou wrote:
It would be pretty difficult to provide any kind of help for this
problem, as there is no source-code or a more specific indication about
the threading code, application, database.

It could be from a threading race condition to a database lock to
resources exhaustion.

Now, for your second question, by using ThreadPool you pick a thread
from the ThreadPool (whenever and if it's available) and you ensure
that the thread will be returned to the pool and you won't have an
arbitary number of thread running.

What you will follow is a matter of requirements.

Regards,
Tasos

venkat wrote:
> Hi,
> I have a page that calls a sql procedure and it runs for 20 - 40 min. I
> use usual threading for this page.
>
> <code>Thread objthread = new Thread(new ThreadStart(ticketingThread));
> objthread.Start();</code>
>
> As i dont know when it will end. i never abort the thread. what happens
> is when user uses the page for 1 week, the page starts hanging. I dont
> know what happens. When i tried debugging it works fine.
>
> I also saw creating thread in threadpools
>
> <code>ThreadPool.QueueUserWorkItem(new
> WaitCallback(ticketingThread));</code>
>
> Please advise which one I have to follow and what is the difference
> between the two.
>
> Thanks
> Venkat

Jun 12 '06 #4
Venkat,

You said this was maintenance work. Why not just run the stored
procedure as a scheduled job? Why are you calling it from a web page
anyway?

Brian

venkat wrote:
Thanks Tasos,
The scenario is I have a button that initiate the ticket processing.
(You can call it like a batch process). It calls a procedure and it
internally calls number of procedures. If the number of items to be
processed is less, then it will take 10-25 min, and max is 40 min. This
is a maintenence work. The existing code works very well but. on due
course the particular page starts hanging. there is no spl code in
that. It has two drop down with two items in it. on slections of those
items user has to click initiate process button. If I restart www
service it starts working fine. that is why I came in to conslusion the
problem is with the threads. (is this correct).

Thanks
Venkat


Jun 12 '06 #5
Hi,

"Brian Gideon" <br*********@yahoo.com> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.com...
Venkat,

You said this was maintenance work. Why not just run the stored
procedure as a scheduled job? Why are you calling it from a web page
anyway?


Probably cause the parameters change, It's ok to call it from a webpage,
it's not waiting for the result to show in the webpage though.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jun 12 '06 #6
Ken
Brian Gideon wrote:
Venkat,

You said this was maintenance work. Why not just run the stored
procedure as a scheduled job? Why are you calling it from a web page
anyway?

Brian

Venkat,

We have a number of processes that take some time to execute. There is
just no way for us to run these things from the web server. If
possible, it is best to run them on a separate processing computer.

We use several queue tables, where the user (or another process)
inserts a request to do something. The process, running on a separate
computer sees this request in the queue, does it's processing and
e-mails the requestor that the process is done.

We tried threads on the webserver but there were many problems. It
just didn't work well. Plus, by placing the heavy-duty processing on
seperate PCs, the web server can do what it does best... Serve web
pages.

Ken - KC7RAD
www.aninetworks.com

Jun 12 '06 #7

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...
2
by: Egor Bolonev | last post by:
hi all my program terminates with error i dont know why it tells 'TypeError: run() takes exactly 1 argument (10 given)' =program==================== import os, os.path, threading, sys def...
77
by: Jon Skeet [C# MVP] | last post by:
Please excuse the cross-post - I'm pretty sure I've had interest in the article on all the groups this is posted to. I've finally managed to finish my article on multi-threading - at least for...
6
by: CK | last post by:
I have the following code in a windows service, when I start the windows service process1 and process2 work fine , but final process (3) doesnt get called. i stop and restart the windows service...
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...
11
by: Paul Sijben | last post by:
I am stumped by the following problem. I have a large multi-threaded server accepting communications on one UDP port (chosen for its supposed speed). I have been profiling the code and found...
17
by: OlafMeding | last post by:
Below are 2 files that isolate the problem. Note, both programs hang (stop responding) with hyper-threading turned on (a BIOS setting), but work as expected with hyper-threading turned off. ...
0
by: kingcrowbar.list | last post by:
Hello Everyone I have been playing a little with pyGTK and threading to come up with simple alert dialog which plays a sound in the background. The need for threading came when in the first...
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...
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:...
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: 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?
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...
0
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,...
0
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,...
0
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...
0
tracyyun
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...
0
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...

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.