473,511 Members | 16,864 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3087
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
6663
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
2954
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
5209
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
555
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
2231
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
4989
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
6389
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
1569
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
2352
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
6609
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
7138
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...
0
7355
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,...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7510
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
5668
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4737
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...
0
3225
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...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.