473,395 Members | 1,937 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,395 software developers and data experts.

help with crashing application

Hello
Working with system.threading.thread

Ok
I have an windows user control. It has 3 thread on it
thread 1 uploaded files types a
thread 2 upload files types b
thread 3 upload files types c

this all happens at same time Works great
Now i put a tab control on my form
i create 5 instances of my windows user control.
which allows me to have 5 different controls working at the same time

Now i start all controls to upload. after each upload the thread sleeps
depending on which tab it is on. There was a speed issue with the
application moving faster then the upload so I had to pause the thread
So My Problem is
system.invalidoperationexecption
there were not enough free threads in the threadpool
question 1:
how meny threads do you get to work with

question 2:
can you change the max number of threads in the pool
Thanks

Chris
Nov 21 '05 #1
3 1561

By default there are 25 threads per processor.

How are you using the thread-pool threads? When you use
QueueUserWorkItem if there are not enough threads then the item just
get queued until a thread becomes available. I've queued up thousands
of items (for a test, not production app) to demonstrate to a
colleague how the thread pool worked (he was scared of it).

If you're using the thread pool to generate a thread and then keep
that thread around, then you should not be using thread pool threads
and should just be creating your own threads. Then the only limit is
based on available resources.

HTH,

Sam
On Mon, 21 Mar 2005 10:53:23 -0600, "Chris Calzaretta"
<cc*********@hotmail.com> wrote:
Hello
Working with system.threading.thread

Ok
I have an windows user control. It has 3 thread on it
thread 1 uploaded files types a
thread 2 upload files types b
thread 3 upload files types c

this all happens at same time Works great
Now i put a tab control on my form
i create 5 instances of my windows user control.
which allows me to have 5 different controls working at the same time

Now i start all controls to upload. after each upload the thread sleeps
depending on which tab it is on. There was a speed issue with the
application moving faster then the upload so I had to pause the thread
So My Problem is
system.invalidoperationexecption
there were not enough free threads in the threadpool
question 1:
how meny threads do you get to work with

question 2:
can you change the max number of threads in the pool
Thanks

Chris


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 21 '05 #2
I am not using a thread pool. what i am doing is
windows Form
tab control
tab 1
windows control file uploader
Thread 1 upload files a
thread 2 upload files b
thread 3 upload files c
tab 2
windows control file uploader
Thread 1 upload files a
thread 2 upload files b
thread 3 upload files c

tab 3
windows control file uploader
Thread 1 upload files a
thread 2 upload files b
thread 3 upload files c

on tab 1 2 and 3 there is a addfiles button.
on click of that button i say
thd = new system.threading.thread(addressof sub)
thd2 = new system.threading.thread(addressof sub)
thd3 = new system.threading.thread(addressof sub)
so on tab1 tab 2 and tab 3 when files uploading there should be a total of 9
threads started and running. plus the 1 for the application it self. so 10
total threads

I dont need an answer here I have changed how my code works. but if you
could post your threadpool sample code that would be great.
I fixed the problem by taking off all tabs but 1 and making it a que update.
So i have a tmr watching a collection of items. if it has any it will start
3 threads and do the work.

Thanks

Chris


"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:eh********************************@4ax.com...

By default there are 25 threads per processor.

How are you using the thread-pool threads? When you use
QueueUserWorkItem if there are not enough threads then the item just
get queued until a thread becomes available. I've queued up thousands
of items (for a test, not production app) to demonstrate to a
colleague how the thread pool worked (he was scared of it).

If you're using the thread pool to generate a thread and then keep
that thread around, then you should not be using thread pool threads
and should just be creating your own threads. Then the only limit is
based on available resources.

HTH,

Sam
On Mon, 21 Mar 2005 10:53:23 -0600, "Chris Calzaretta"
<cc*********@hotmail.com> wrote:
Hello
Working with system.threading.thread

Ok
I have an windows user control. It has 3 thread on it
thread 1 uploaded files types a
thread 2 upload files types b
thread 3 upload files types c

this all happens at same time Works great
Now i put a tab control on my form
i create 5 instances of my windows user control.
which allows me to have 5 different controls working at the same time

Now i start all controls to upload. after each upload the thread sleeps
depending on which tab it is on. There was a speed issue with the
application moving faster then the upload so I had to pause the thread
So My Problem is
system.invalidoperationexecption
there were not enough free threads in the threadpool
question 1:
how meny threads do you get to work with

question 2:
can you change the max number of threads in the pool
Thanks

Chris


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.

Nov 21 '05 #3

Here's the thread pool test I put together earlier. It queues up 500
items and they run and report when they start and finish. See how it
ramps up to 25 or 50 active threads (depending on number of
processors) and then at end slows back down to 0 active threads.

HTH,

Sam
Imports System.Threading

Public Class ThreadTest
Const THREAD_COUNT As Integer = 500
Private Shared _done As Integer = 0
Private Shared _active As Integer = 0
Private Shared _states(THREAD_COUNT - 1) As StateInfo

Public Shared Sub Test()
Dim workerThreads As Integer
Dim completionPortThreads As Integer
ThreadPool.GetMaxThreads(workerThreads, completionPortThreads)
Console.WriteLine("max threads: " & workerThreads & ", " &
completionPortThreads)

Console.WriteLine("Starting Test...")
For i As Integer = 0 To THREAD_COUNT - 1
Console.WriteLine("Starting thread " & i )
_states(i) = New StateInfo(i)
ThreadPool.QueueUserWorkItem(AddressOf Test2, _states(i))
Thread.Sleep(10)
Next
Console.WriteLine("Finished queueing threads...")

Do While _done < THREAD_COUNT
Thread.Sleep(250)
Loop
End Sub

Public Shared Sub Test2(ByVal state As Object)
Dim stateInf As StateInfo = DirectCast(state, StateInfo)
Dim id As Integer = stateInf.ThreadID

SyncLock _states
_active += 1
End SyncLock
Console.WriteLine("In Thread " & id & ", active " & _active & ",
beginning loop")
Thread.Sleep(3000)
Console.WriteLine("In Thread " & id & ", active " & _active & ",
finished loop")
stateInf.Done()

SyncLock _states
_active -= 1
End SyncLock
End Sub

Public Class StateInfo
Public ThreadID As Integer
Public Sub New(ByVal threadID As Integer)
Me.ThreadID = threadID
End Sub
Public Sub Done()
SyncLock _states
_done += 1
End SyncLock
End Sub
End Class

End Class


On Mon, 21 Mar 2005 13:21:47 -0600, "Chris Calzaretta"
<cc*********@hotmail.com> wrote:
I am not using a thread pool. what i am doing is
windows Form
tab control
tab 1
windows control file uploader
Thread 1 upload files a
thread 2 upload files b
thread 3 upload files c
tab 2
windows control file uploader
Thread 1 upload files a
thread 2 upload files b
thread 3 upload files c

tab 3
windows control file uploader
Thread 1 upload files a
thread 2 upload files b
thread 3 upload files c

on tab 1 2 and 3 there is a addfiles button.
on click of that button i say
thd = new system.threading.thread(addressof sub)
thd2 = new system.threading.thread(addressof sub)
thd3 = new system.threading.thread(addressof sub)
so on tab1 tab 2 and tab 3 when files uploading there should be a total of 9
threads started and running. plus the 1 for the application it self. so 10
total threads

I dont need an answer here I have changed how my code works. but if you
could post your threadpool sample code that would be great.
I fixed the problem by taking off all tabs but 1 and making it a que update.
So i have a tmr watching a collection of items. if it has any it will start
3 threads and do the work.

Thanks

Chris


"Samuel R. Neff" <bl****@newsgroup.nospam> wrote in message
news:eh********************************@4ax.com.. .

By default there are 25 threads per processor.

How are you using the thread-pool threads? When you use
QueueUserWorkItem if there are not enough threads then the item just
get queued until a thread becomes available. I've queued up thousands
of items (for a test, not production app) to demonstrate to a
colleague how the thread pool worked (he was scared of it).

If you're using the thread pool to generate a thread and then keep
that thread around, then you should not be using thread pool threads
and should just be creating your own threads. Then the only limit is
based on available resources.

HTH,

Sam
On Mon, 21 Mar 2005 10:53:23 -0600, "Chris Calzaretta"
<cc*********@hotmail.com> wrote:
Hello
Working with system.threading.thread

Ok
I have an windows user control. It has 3 thread on it
thread 1 uploaded files types a
thread 2 upload files types b
thread 3 upload files types c

this all happens at same time Works great
Now i put a tab control on my form
i create 5 instances of my windows user control.
which allows me to have 5 different controls working at the same time

Now i start all controls to upload. after each upload the thread sleeps
depending on which tab it is on. There was a speed issue with the
application moving faster then the upload so I had to pause the thread
So My Problem is
system.invalidoperationexecption
there were not enough free threads in the threadpool
question 1:
how meny threads do you get to work with

question 2:
can you change the max number of threads in the pool
Thanks

Chris


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.


B-Line is now hiring one Washington D.C. area VB.NET
developer for WinForms + WebServices position.
Seaking mid to senior level developer. For
information or to apply e-mail resume to
sam_blinex_com.
Nov 21 '05 #4

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

Similar topics

1
by: Adam Hearn | last post by:
Sorry if this difficult to understand but I'm pulling my hair out and could do with some good ideas please... I've developed an application which in .NET as a Windows service which is simply...
7
by: JN | last post by:
Hello. Sorry about the length of this post. I am trying to implement a hash table for my chess program, and decided to try using the VC++ . NET (Dinkumware) version of hash_map. The role of the...
2
by: pratchaya | last post by:
This is my sample error in my MySQL Log New value of fp=(nil) failed sanity check, terminating stack trace! Please read http://www.mysql.com/doc/en/Using_stack_trace.html and follow instructions...
0
by: jphelan | last post by:
I have a subform that works fine until you import it into a new database when it crashes if you try to open it in either disign or form view. The form, "Attendees_Subform" in my application was...
0
by: John Phelan Cummings | last post by:
I have a subform that works fine until you import it into a new database when it crashes if you try to open it in either disign or form view. The form, "Attendees_Subform" in my application was...
2
by: devendra pardeshi | last post by:
hi friends/seniors i am stuck on one problem in VB 6.0 and need solution. see if u can help me. first i describe the problem. Can u imagin the WinZip scenario. we right click on some file...
1
by: ankit | last post by:
I made a Cpp application wihich links with shared objects. But when I runs the application, it crashes surprisingly before entering into the main() control block. After trying with gdb I came to...
3
by: Adam Clauss | last post by:
We have a Windows service written in C#. As of late, it has started crashing after running for as little as 2 minutes. I have a handler for AppDomain.UnhandledException which does NOT get called...
5
by: xoinki | last post by:
hi all, I have a very general question.. My program is crashing in a window procedure... the sample code is as follows.. return CallWindowProc(pccustgrid->m_wporiglistwndproc, hwnd,...
2
by: =?Utf-8?B?QW5uZXh4eHh4eHg=?= | last post by:
My computer keeps crashing. The files created when it does this are: WERdc15.dir00\Mini090708-03.dmp WERdc15.dir00\sysdata.xml has anybody any idea of what these files are and the solution to...
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: 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
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?
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
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
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
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,...

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.