"Looping" A Threadpool For Loop?

Dec 3, 2010

So I'm running a For loop that creates a ThreadPool thread and executes a task. Once the For loop finishes, I'd like it to "start over" and do the same thing. Now this obviously causes an infinite loop if I don't do it right.

what I'm kind of wondering is; is there a way to "keep" those threadpool threads active and constantly performing a task? it seems like they get disposed of once their "task" is complete.

Right now, the thread connects to a webservice, captures some data, stores it in a List(of String). This ultimately builds a ListView with the data. One of the columns is a "count" and i'd like to keep updating that count continually.

View 4 Replies


ADVERTISEMENT

VS 2008 2 Threadpool - One Threadpool For Scanning Files And Second Threadpool For Moving File's Into Drive's

Jun 4, 2011

I m trying to move all my drive's files into h drive firstly i have added all drives in threadpool for scanning and when scanning of any drive finish (Without waiting for other drive's complete ) it will move file's to h drive but it is not working as i wanted that's why i need two threadpool - one threadpool for scanning files and second threadpool for moving file's into drive's

View 11 Replies

VS 2010 Looping And Freezing - Add All The Users To A Threadpool To Do A Certain Function?

Jan 16, 2012

I have a code which adds each line of a textfile to a List(Of String).I have around 1.5 million entries in the textfile. It adds it to the list in like 1 second. However, I'm trying to add all the users to a threadpool to do a certain function. So I try:

For i as integer = 0 to list.count - 1

The list has like 1.5 million entries so the GUI freezes untill it all finishes in like 5 minutes. How can I make it go faster and not freeze the GUI?

View 6 Replies

Number Looping Using For Loop?

May 17, 2012

I am trying to loop number into something like this.

0
12
345

[code].....

View 7 Replies

Looping Through Different Textboxes With One Loop Code

Jun 1, 2010

i know there are no "control arrays" in vb.net. i do come from vb6, and im trying my way now within bv.net, so please be gentel...

if someone could please post a simple code to do the following, it would be great:

i have 3 textboxes called txtBet1, txtBet2 and txtBet3.

i have another 3 texboxes called txtResult1, txtResult2, txtResult3.

so i want to have one loop code, to get the value in txtBet1, calculate somethings, and put it into txtResult1.text.

i know it's basic, but i tried using this sample here as a reference, but its not really understandable for me, because its not really choosing the exact control i want to address...

this is from Microsoft website - a comparison between vb6 and vb.net:

"' Visual Basic 6.0
Private Sub ClearText()
For i = 0 To Text1().UBound

[Code]....

View 5 Replies

VS 2005 Loop Doesn't Keep Looping?

Feb 22, 2010

I'm making a rock paper scissors program and once I set the current_scene variable to 1, the MainLoop() sub doesn't keep looping, but the sub doesn't exit either. (Form1.vb is the most important file.)

View 9 Replies

For Loop Hanged When Large Looping Process?

Jun 8, 2011

I have a for loop like

For eacj obj as PsObject in psoObjCollection
For i =0 to 25
Rows.Add("sss")=obj.Members("sss").value

[code].....

View 8 Replies

Loop/design - Looping Through A Database With Pdf Locations

Sep 14, 2011

I am looping through a database with pdf locations. The application is button click event driven. The problem I am having is that I display a pdf. If the user clicks on the button then the pdf information is inserted into a database and the loop should be taking me to the next pdf. However, this loop does not seem to give what I need. What ends up happening is the first pdf gets displayed twice. I think mainly because I display the first pdf onload, but when I click the button it agrees and grabs the first item from the database. And it ends up falling behind because its restarting the query and I cant quite figure out how to get the button to catch the first displayed pdf, or skip it entirely since I am using a welcome pdf. So on the welcome pdf that is supposed to be displayed initially the user clicks agree and it agrees to the welcome pdf instead of just skipping it. I am not quite sure how to just move past the pdf.

public sub onload()
display the welcome pdf
end sub

[CODE]...

Now if I run the code without the loop it works fine. I just end up having to run the app however many pdfs I have in my database.

query data
display data
insert data
Windows.Forms.Application.Exit()

To display pdfs I imported the com control for adobe so pdfs get displayed like this:

axacropdf1.src = my.mysettings.default.readpath & pdflocation

pdflocation is passed from a query fill.

I think I have an underlying design issue which probably precedes the loop.

View 4 Replies

Console Application / MsgBox While Looping Without Interrupting Loop

Jul 19, 2009

Im working on a console application, and i need my application to open message boxes without stopping/interupting/pausing the loop. I have been trying to make it open another application which spawns the messageboxes, but then every message box comsumes ~4MB RAM which becomes a problem when to many gets opened.

View 12 Replies

Forms :: Pausing A Running While Loop And Wait For Certain Button Until The Looping Resumes?

May 17, 2010

I'd like to make a simple program where my form consists of a textbox and a button. Here's the ide in a nutshell:in form1_load I invoke the sub:

private Sub LoopingLesson()
dim i as integer=1
while true

[code]....

what I want is when i hits certain value, like let's just say i is divisible by 365, then the 'while' looping will stop, and a message box saying "target reached" appear. then after I click button1, the looping will resume until it reaches the next number divisible by 365, and so on.

View 10 Replies

ThreadPool And Delegate In C# To .NET?

Jan 1, 2010

how this is written in VB.NET? This was an example I found on [URL]

ThreadPool.QueueUserWorkItem(delegate
{
var channelFactory = new ChannelFactory<ISimpleService>("*");
var simpleService = channelFactory.CreateChannel();
var asyncResult = simpleService.BeginGetGreeting("Daniel", null, null);

[code]....

View 3 Replies

.net - Threadpool Using Upto 200 Threads?

Jun 26, 2011

i have this code which i run with queued 10,000, even when a max of 50 is set but the threadpool counts goes to high.

Public Sub DoWork(ByVal objItem As Object)
Dim objUrl as String = DirectCast(objItem, string)
Try
If objUrl Is Nothing Then

[code]....

EDIT:i use a this code to check the number of runing threads each second

Sub Timer1Tick(sender As Object, e As EventArgs)
tsslthreads.Text=string.Format ("Threads: {0}", Process.GetCurrentProcess().Threads.Count)
End Sub

View 3 Replies

Async Callback From ThreadPool?

Jun 12, 2009

I have a bunch of operations that need to be executed simultaneously. For this I'm using the thread pool to execute the tasks. I'd like to know if it's possible to consume some sort of Async Callback (similar to BackgroundWorker.DoWorkComplete) when each thread is finished. The reasoning behind this is that I have a windows service running that uses IPC to update a GUI and I need to know the time at which each specific thread finishes I've used background workers to do a set of tasks and they work perfectly, however, they take longer than I would like. I've timed the execution on my BGW method for a designated number of said tasks and it took 27 seconds, and the same set of tasks takes 4 seconds using the threadpool method. I've also tried using managed threads, to the same effect as the background workers.

View 5 Replies

Difference Between ThreadPool And BackgroundWorkers?

Jan 11, 2009

I'm currently writing an application that is used to automate a certain task. Currently, it uses the threadpool (using up to 25 threads per the enduser's option). Each thread calls a function which will usually take about two minutes to finish, but it uses a While loop in order to repeat the process. This is my code to start the threads:

Private Sub ProcessAllItems()
For i As Integer = 1 To Me.numThreads.Value Step 1
Threading.ThreadPool.QueueUserWorkItem(New Threading.WaitCallback(AddressOf ProcessItem), i)
Next i
End Sub

The function "ProcessItem()" is the function that contains the While loop. The control "Me.numThreads" is a NumericUpDown control whose max value is set to 25. My question is...is this a good method to follow? To my knowledge after .NET Framework SP1 there is a max of 250 threads/CPU. However I've read the the threadpool is normally used for processing short-lived tasks. Should I be using background workers instead? If so, how could I start up to 25 background workers during runtime depending on the value of "Me.numThreads"?

View 14 Replies

Forms :: Threadpool With Progress Bar?

Jul 2, 2009

currently i am using a threadpool that contain a number of thread. This number of thread can be different everytime, sometimes 5, sometimes 10, sometimes 15 and so on (multiple of 5). So now i have it working good by using for loop to queue the thread into threadpool. Now the problems is i do not know how to make the progress bar depending on my threadpool. I want my progress bar to complete only when all the thread are done. After searching google, i found that maybe it can be solve by using AutoResetEvent(false), but after i apply to my program, it still did not work, my program hang at xEvent.WaitOne() method and didnt proceed further, anyone can explain to me how to solve the problem? Or got any other ways? For your information, only 5 threads can be running at the same time as the requirement state so (so i set the setmaxthread to 5 already).

View 1 Replies

Not Enough Free Threads In ThreadPool

Mar 15, 2011

anybody familiar with these error? "There were not enough free threads in the ThreadPool object to complete the operation".im calling a web service in my windows application client.

View 16 Replies

Threadpool And Threading In General?

Jun 5, 2010

whipped up this code real quick which uses a ThreadPool on Form Load to iterate through my subnet and tell me if there's a device communicating at each IP address.

some questions: Why am I able to update BOTH my label at the top AND the listbox, but I'm only using an .Invoke on the Listbox?How can I know how many threads are currently being used while that is executing?

What does the SyncLock do?I'm aware some people don't like the use of Application.DoEvents(). Is it ok to be using it in this instance or is there a better practice?For those wanting to try it out, drag a Label and a Listbox to a new form. Label is called "currentIPTextbox", Listbox is default name.

[Code]...

View 14 Replies

ThreadPool Not Working In Parallel

Feb 12, 2010

I prepare data to be processed, and saved to file. Since this process is slow, I want to delegate it to a parallel thread, so the main routine can end his work faster. The data is processed and saved to file by the "Sub ProcesarDatos", a routine on his instance of "FileProcessor class".

I call the code this way:
Dim
fp As
New
FileProcessor(DatosDeArchivo, Archivo & ".txt", Me)
ThreadPool.QueueUserWorkItem
(NewSystem.Threading.WaitCallback _
AddressOffp.ProcesarDatos))

View 2 Replies

ThreadPool.QueueUserWorkItem Sometimes Slow?

Feb 14, 2012

I am using VB.NET 2008.Every now and then, ThreadPool.QueueUserWorkItem can take up to 500 msI checked the available thread, and it's not 0.What can cause ThreadPool.QueueUserWorkItem to take long sometimes, and how can I make it faster ?

Do While Not TerminateRisk
While qRiskSync.Count > 0
sItem = qRiskSync.Dequeue

[code]....

View 1 Replies

VS 2008 - Threadpool Example For Scraper

Mar 9, 2012

can somebody give ThreadPool example for application thats needs to get information to datagridview from thousands of sources? My application needs to work fast and without freezing and lag, but I cant figure out this threadpool thing. And would be nice if you could add this thing to example that when I set domainupdown value to 25 as example, it sets threads to 25. So its making work 25x faster. I haven't find any good example for this, only some C# examples but they haven't work after i converted those to vb.net.

View 1 Replies

VS 2008 How To Stop Threadpool

Nov 20, 2009

I have a app that gathers and store updated data from a list of websites. My app use threadpool and each thread visits a site within the list and gathers the data. I want to create a stop button to stop/ prevent threadpool from running once it is clicked. How do I go about doing this?

View 1 Replies

VS 2008 Threadpool With Progress Bar?

Jul 1, 2009

currently i am using a threadpool that contain a number of thread. This number of thread can be different everytime, sometimes 5, sometimes 10, sometimes 15 and so on (multiple of 5). So now i have it working good by using for loop to queue the thread into threadpool. Now the problems is i do not know how to make the progress bar depending on my threadpool. I want my progress bar to complete only when all the thread are done. After searching google, i found that maybe it can be solve by using AutoResetEvent(false), but after i apply to my program, it still did not work, my program hang at xEvent.WaitOne() method and didnt proceed further, anyone can explain to me how to solve the problem? Or got any other ways? For your information, only 5 threads can be running at the same time as the requirement state so (so i set the setmaxthread to 5 already).

View 2 Replies

Forms :: Opening Form Using A Threadpool?

Sep 15, 2009

I want to open a VB.net form using a ThreadPool with a maximum of 10 threads. I need to do this because, the form should open based on a live event and i need atmost 10 forms on the desktop at a time. If i open the form on every live event without using a ThreadPool, the desktop will be floaded with many forms. I am using QueueUserWorkItem method of threadpool to queue a method which opens the form. In this queued method, there is form1.show() statement called. But after displaying the form, this method finishes execution and again we have 10 threads available in the system. I somehow want to either keep this method running so that 1 thread is occupied or i want to keep the thread alive till the form1 is closed by the user. I want the 11th form to appear on the desktop, only when any of the existing forms out of the 10 (already on desktop) is closed.

View 2 Replies

Keep Object Alive For Threadpool / Timercallback?

Jun 4, 2009

When using teh system.threading.timer or threading.threadpool. queueuserworkitem, you are able to pass an object.

But wouldn't the garbage collector destroy the object even before the callback can be executed?[code]...

View 2 Replies

ThreadPool And Large Processing Of WorkItem?

Oct 11, 2010

Been trying to implementing ThreadPool over a large and variable amount of data like the following:

public sub ProcessWorkItem(byval state as object)
Dim originalState as CustomStateInfo = CType(state, CustomStateInfo)
'Do stuff

[Code]....

This of course will bomb out if we have more than 64 items/threads being placed on the ThreadPool.

So, how would one process say x amount of items until there are no more items left to process?

View 30 Replies

Use ThreadPool Without Making Sub Foo(o As Object) Each Time?

Feb 7, 2010

Every time that I want to make a thread in the ThreadPool I make a stupid little function like Worker_O below.[code]...

Is there a way in VB .net to cast from Sub(i as integer) to Sub(o as object) without making Worker_O? Worker_O is ugly to me.

View 1 Replies

Canceling A ThreadPool Thread That's Being Blocked By A .NET Method?

Aug 14, 2009

I have a task that needs to be executed many times in a thread, so as to keep my GUI responsive. Right now I'm using the ThreadPool to accomplish the tasks, and it works perfectly. I get all the data I expect back from the threads, life's good. When those tasks are finished, I then fire off another set of threads to accomplish another set of tasks, in the same fashion. The work method of these threads uses a call to RegistryKey.OpenRemoteBaseKey, which does exactly that, opens a remote registry key. The problem is: if the user running the application does not have permission to open the remote registry the call will throw an IOException, but I expect this behaviour because the user does not have permission to do it. However, the call itself can take FOREVER.

I wrote the application initially to use delegate methods and used the WaitHandle.WaitOne() method on AutoResetEvents in a state object I passed to each delegate. I tried the WaitOne method using a timeout, which worked fine until I realized that even though the WaitOne timed out, the thread was still running. This is a problem because (from what I understand) processes are only given a certain number of ThreadPool threads and, once used, they must be finished in order to be released back to the threadpool. In my work method, I also have a variable that can be signalled when the thread should be stopped, but that (obviously) only works on code that I've written.how can I cancel a thread that's stuck on a .NET method? Is there some sort of garbage collection method I can call if I give it a handle?

View 18 Replies

Incompatible Signatures When Spawning Thread With ThreadPool?

May 5, 2009

The error is:

Method 'Private Sub ProcessToolWork()'
does not have a signature compatible
with delegate 'Delegate Sub

[code].....

View 2 Replies

Make Threadsqueued To Threadpool Execute Sequentially?

Sep 13, 2011

Learning about threads at the moment, barely managing to wrap my head around it, anyway I was wondering how you would go about making threads run sequentially from threadpool if you added them with
threadpool.queueuserworkitem()

In my code currently I know it is not running sequentially as I set it up to call a function and print a number each call. I gather this could be achieved with using synch lock but not quite sure how.

View 5 Replies

Threadpool Threads Detect Finished Processing

Jun 28, 2011

what is the best way of detecting if all the threads in the threadpool have finished working,

is there anyway to stop all the threads?

[URL]

View 8 Replies







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