What Is The Max Number Of Threads In The Thread Pool

Sep 22, 2009

I've been reading up on multi-threading and just have a couple trivia questions that are ambiguous given my sources:

1) What is the max number of threads in the thread pool? The number 25 is used but I have on reference that says 25 per CPU and another that says 25 per core. I realize that both can be right but before I start making flagrant design decisions I'd like some validation.

2) Let's say I'm in the body of a delegate and I call a function or sub. Does that function/sub remain in the thread or does it revert to the parent thread? I'm guessing the former would be much easier to implement so that's probably what MS did but you just can never tell.

View 10 Replies


ADVERTISEMENT

Running Threads In Thread.Pool Sequential?

May 19, 2012

I have several threads in my WinForm and I am running them via Thread.Pool, what I need to know is that how can I run them sequentially.

example:

Thread1 => me.label1.text = "Thread1"
Thread2 => me.label2.text = "Thread2"
Thread3 => me.label3.text = "Thread3"

In my Form_Load event, I have a line as follows:

[Code]...

View 8 Replies

Trap Exceptions In Thread Pool Threads?

Jun 15, 2012

I have a thread pool that send file using ftp protocol. I encapsulated the call for threadpoll with try catch believing that the thrown exception inside the threadpool will be catch by the main thread. Instead the system terminate whenever i throw an exception from inside the threadpool. Also I design the Clsftp.ftpsend class to throw an exception related to ftp error. Basically my design for handling the error is just like the code below.

'Main thread
Private Sub BttnStartSending_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BttnStartSending.Click
try
Dim objparam As New ThreadParameter

[code]....

View 7 Replies

1 To N Thread - Show A Definite Number Of Threads?

Sep 3, 2009

Does anyone have a 1 to n thread example in which n threads are created dynamically? There are a number of examples that show a definite number of threads, and some that imply n threads by using a tcp ip listener or a file system listener. However, I'm looking for a 1 to n created in response to a dynamic requirements, provided purely by and for my program.Essentially, my requirement is to be scalable. 1 to n threads based on application throughput should make this pretty easy to satisfy.

View 9 Replies

Waiting For Threads - Thread.join Suspend Execution Of Code On Calling Thread Until Spawned Thread Finishes Or Is Aborted

Sep 2, 2010

My understanding is that thread.join will suspend the execution of code on the calling thread until the spawned thread finishes or is aborted...

With that in mind, I tried this:

For i = 1 to 50
threads = New Thread(AddressOf test)
threads.IsBackground = True
threads.SetApartmentState(ApartmentState.STA)

[CODE]...

However, the rest of the code runs when the loop finishes, not waiting for all the spawned threads to finish. Since the rest of the code needs the threads to finish (otherwise the rest will error).

View 4 Replies

How To Add Thread Pool To This

Mar 8, 2009

I have a code that basically grab data from a file, split into array and use a FOR loop to input data into a different file. I want to use thread pool to create multiple threads to do a specific task. For example for the array() I want a thread to read the first item in a array and perform the task, a second thread reads the second item and perform the task, a third thread reads the third item and perform the task, etc. How would I add thread pool to something like:

Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim data As String

[code]....

View 1 Replies

Implements A Thread Pool With Webrequest?

May 24, 2012

I have about 1000 webrequest created. Each link will navigate to a website and download a picture to place into a picturebox.

The person will then type in what animal is in the picture into a textbox. Then the user will then hit the submit button to send the name of the animal back to the site.

I am going to implement the use of a thread pool to handle the threading portion of those requests.

What is the best method to get my webrequest into the thread pool (listbox, txt file,etc?) and then how can I setup my button to coordniate with the site that is coming out of the pool to the picture box?

My first thought is to create everything on the fly. The picturebox, the textbox, and the submit button, the webrequest to the site for the picture and back again for the result. Something tells me that I will be taking the long way around to get same result.

My second thought is to have a slew of pictureboxes, textboxes, and buttons already on my screen and then when they come out of the pool and into a thread they would assigned a picturebox, textbox, and button if the others are not busy.

View 4 Replies

Read All Txt In A Folder Into A Thread Pool?

May 29, 2012

I am going to implements a thread pool to run my application. All of my content is saved under a folder on my desktop.

Each of the files are in .txt format. How can I read each .txt from a given folder and then put the .txt file into the thread pool / thread queue?

View 1 Replies

Way To Implements A Thread Pool With Webrequest?

May 25, 2012

I have about 1000 webrequest created. Each link will navigate to a website and download a picture to place into a picturebox.The person will then type in what animal is in the picture into a textbox. Then the user will then hit the submit button to send the name of the animal back to the site.I am going to implement the use of a thread pool to handle the threading portion of those requests.My question is this:What is the best method to get my webrequest into the thread pool (listbox, txt file,etc?) and then how can I setup my button to coordniate with the site that is coming out of the pool to the picture box?My first thought is to create everything on the fly. The picturebox, the textbox, and the submit button, the webrequest to the site for the picture and back again for the result. Something tells me that I will be taking the long way around to get same result.

View 2 Replies

How To Read All .text In A Folder Into A Thread Pool

May 29, 2012

I am going to implements a thread pool to run my application. All of my content is saved under a folder on my desktop.Each of the files are in .txt format. How can I read each .txt from a given folder and then put the .txt file into the thread pool / thread queue?

View 2 Replies

Safe While Using A Thread Pool With A Global Mysqlconnection?

Mar 1, 2011

Im creating a service for a mobile platform and I need to process user messages on a different thread than they were created on to leave the threadpool open.Anyway my App will be using a MySQL database and when it gets a message it will add the message to Another thread pool. But in the sub that procceses the messages I will need to perform query's on the database. So i know i can use a global variable and it will be visible to all threads but is making database operations safe while using a thread pool with a global mysqlconnection?

View 2 Replies

Thread Pool Download Multiple Files At Once?

Sep 2, 2009

I'm trying to use the thread pool to download more than one string at a time. But most of the tutorial on threading is in C# or C++ so my knowledge on thread pool is limited.

Here's what I got so far.

Imports System.Threading
Imports System.Net
Imports System.Text.RegularExpressions

[Code]....

I keep getting an error "Cross-thread operation not valid: Control 'Listbox1' accessed from a thread other than the thread it was created on." And it still seems to be downloading it one by one to me.

View 10 Replies

C# - Prevent System.Timers.Timer From Queuing For Execution On A Thread Pool?

Feb 2, 2011

There is a problem with standard System.Timers.Timer behaviour. The timer raise Elapsed event with some interval. But when time of execution inside Elapsed event handler exceed timer interval then thread pool begin queuing event handling. This is a problem in my case. This is because with my Elapsed event handler I fetch some data from database and doing something with it and finally save results back to database. But data handling should be provided only once. So, is there a way to prevent from queuing elapse events for System.Timers.Timer.

As illustration for this issue you can consider next test program:

[code]...

2) Second way is about SynchronizingObject, but it is a valuable only for Windows form application or required additional development of code for implementing object that would be implements ISynchronizeInvoke interface. More about this way you can find here

View 4 Replies

C# - Read Printer Pool To Get Number Of Pages Being Printed

Aug 12, 2010

I have a network printer in the classroom lab. I'd like to keep record of how many pages of each student has printed. I want to know how can I read the printer pool to get the number of pages, when a student prints. Here's what I have in mind: Write a Windows service to get:

[Code]...

View 1 Replies

Running All Threads Not On The GUI Thread?

Dec 7, 2011

I have only managed to use an STA to run a long running excel process with a background worker and 2 delegates.

What I want to do now is have the whole application running outside of the main thread to make sure the UI is always available, I then want to create new threads from the thread I have outside of the main to run the various processes. I will need to have some form of syncronisation in there for certain things to be done once a thread is completed and also I will need to change the button states on the main form to stop certain process being called whilst other processes are running.

This is my code so far, basically this loads in a csv file to a datatable adding manager employee ID and email address, filters it and displays the resultant data in a listview. There eventually will be some filter options as well. There are then 2 options for processing the data, it will produce individual bradford factor reports and email them to each manager or will produce a summary spreadsheet that is sent to HR.

Currently because there are around 8000 lines of data, it was the summary option that required the background worker as a long running process time out error was occuring whilst in the main.

What it does is write the data from the list view to an excel sheet and colour co-ordinates the summary rows according to the absense policy. It then copied bottom to top, the summary value the next blank column against all the lines for that individual and then uses this column to decide which sheet to move the row to, copying the row to the new sheet then deleting it from the master list and shifting the cells up.


This works well, but the process of loading the data in to the list view locks up the main thread where it currently runs. I also wanted to make this slightly more complicate as far as threading is concerned, as more of a learning curve than a practical application of the function.

Here is my code so far: [URL]

View 10 Replies

Finding 1 Thread Out Of The 3500+ Threads?

Jan 3, 2010

Trouble finding 1 thread out of the 3568 threads I have in my history.In the one I'm looking for I wrote an Extension Method called Shape , I think.

The code could change the Shape of any Control and I think I added similar code for any FORM in the same thread but not for User Controls.

Does anyone remember roughly what year and month it was?

It might save me hunting through my past threads.

[Code]...

View 4 Replies

VS 2005 Pause A Thread - Let Other Threads Run

Dec 5, 2010

In my application I have a loop that makes calls to a website to download data. I'm using a DownloadDataAsynch call with a handler.

I'm making many such calls in a loop. What I'd like to do is, if I have more than a certain number of replies pending, I should pause the loop and let the data handlers run.

How do I do that?

CODE:

View 14 Replies

Stop All Threads Or Just The Thread That The Statement Is Executed In?

Dec 12, 2010

I'm working with vb.net 3.5SP1 /VS2008. I'm familiar with windows threads from C++ but I didn't do it since the 90s.I have 5 threadpool calls (ThreadPool.QueueUserWorkItem) that do some complex work (they read info from different web pages, regular expressions, etc) and each updates different columns in a data-grid view. They pause for 1 second between each web read with thread.sleep (not to overload the server). My issue is that some of the threads do not complete. I get for example 3 results when I should have 8. Sometimes it works fine. This is an older 3.0Ghz HT machine, I want to test it on the lowest common denominator(and that is all I have ). I tried using Monitor.Enter(ListView1)it seems to help but it is hard to tell. I tried using the thread debug window but it is not really helpful, it seems do disappear during execution. If I remove the threads I always get my data. I'm wondering if something is being blocked? Is there a way to debug this?

Also, does thread.sleep(x) stop all threads or just the thread that the statement is executed in?

View 4 Replies

Enumerating Managed Threads Or Determining When A Thread Is Created?

Feb 15, 2010

I have need of either enumerating all the managed threads in a application or listen to when a new thread is created. I can not find anyway to do this through searching the web. It strikes me as odd the the IDE can list all the manage threads, but I can't.

If this is not possible, is there clarification as to why this is not possible.

I need to create a shared class in a DLL that will when it receives a signal will stop all the threads currently running, and gracefully exit the application.

View 3 Replies

Pass Objects Between Threads Before Child Thread Completes

Oct 15, 2009

What is the best way to pass objects between threads? I would like to create a new thread that creates a new object : Dim myobject as newobject = new newoject Then in my main thread, I would like to use myobject. Ideally I would like to just assign to a global variable but I don't think that is possible. I think I may have to use some form of delegate function (but I think the child thread would need to complete to use a callback). The new thread will not actually end before I need the object reference in the main thread. How should I go about this?

View 2 Replies

C# - Does Queuing Threads Impact Non-thread Safe Objects In The Same Class

May 23, 2011

c# - Does queuing threads impact non-thread safe objects in the same class?

View 1 Replies

Does Queuing Threads Impact Non-thread Safe Objects In Same Class

May 7, 2009

If I spawn a thread with ThreadPool.QueueUserWorkItem and that thread does not reference the object that is not thread safe, would it compromise that non-thread safe object? By not thread safe object, I mean a third party interface to a programmable logic controller that has no ability to open simultaneous connections or concurrency support.I suppose I just wanted to be sure that by queuing threads in the same class as my reference to that object, I wouldn't somehow be compromising its thread safeness in a way I didn't realize.

View 2 Replies

Thread About Threads - Made A Rapid File Transfer Form For Photos?

Apr 29, 2010

I just made a rapid file transfer form for my photos.In which I drag photos into a listview with my destination folder set.I assign each individual file transfer to a new thread. This works very fast as compared to the standard drag n' drop.

View 2 Replies

Run X Number Of Manageable Threads?

Mar 23, 2011

How can I make an application to start only "x" number of threads at a time?

View 1 Replies

VS 2010 Get A Max Of Number Of Threads Available?

Feb 26, 2012

I've written an app - that use httplisteners to talk to other winforms (they will be services but are now simple form apps so I can easily show stats as they communicate). One UI app talking to three other "service" apps - all talking to each other as well...Everything uses multi-threading...At any rate - how many threads do I have available - I see that most of the apps seem to run "two or three" consecutive threads - but not more than that.Is that just a byproduct of running in the IDE - or is there a max of number of threads available?When more threads are asked for than are available - do they simply wait to get started for a free thread to become available?

View 4 Replies

C# - Can The Number Of Foreground Threads Be Determined In .NET

Mar 8, 2011

I've searched a good deal on the topic and have found little results. It seems adding foreground into the criteria on any engine I've used causes tons of entry level documents on threading in .Net.

In my current project I have a foreground thread within a static class that lies dormant until it is told otherwise. It contains a queue of items that must be processed and the items application cannot close without all items being processed. Right now I have a method that tells the thread that it should stop accepting new items and close when it is finished processing everything, but not everyone on the team remembers to call the method. Having the GUI close while the process still runs in the background is quite a bug in my opinion. If I can add a periodic check to see if the queued thread is the last foreground thread, then I can call the method and not have to worry about others that use the class.

View 2 Replies

How To Create A Dynamic Number Of Threads

Jan 6, 2010

Currently I create a thread the following way (the normal way)

Public loginThread As Thread
Public loginThreadStart As New ThreadStart(AddressOf LogIntoWhatever)
Public callLoggedIn As New MethodInvoker(AddressOf loggedIn)

However, what I want to be able to do is something along the lines of (this obviously does not work, and is entirely pseudocode)

dim i as integer = 0
for i = 0 to i = 25
Public loginThread(i) as Thread
Public loginThreadStart(i) as New ThreadStart(AddressOf LogIntoWhatever)
next i
Public callLoggedIn as new MethodInvoker(AddressOf loggedIn)

Where I could change 25 to whatever I wanted and have that number of threads created. They would all be running an identical sub which does do not make calls of any kind to each other, they don't need knowledge of each other. Is anything like this possible?

View 3 Replies

How To Create X Number Of Threads Without Hardcoding

Sep 24, 2010

[code]How do I create X number of threads without hardcoding?Eg. user decides the number of threads

View 1 Replies

Set Limit To The Number Of Threads For BackgroundWorker?

Mar 17, 2011

Is there any way/property to set BackgroundWorker to execute only x number of threads?

View 1 Replies

Start Multiple Threads But Not A Specific Number?

Dec 3, 2009

I want to start multiple threads but not a specific number. For example;

private sub do_sth
...
end sub

[Code]....

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved