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


ADVERTISEMENT

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

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

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

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

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

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

VS 2008 Threads - Create New One Or Re-use Old One?

Apr 9, 2010

I need to 'download' the contents of an XML file that resides on some web address and parse them. I need to do this about once every 5 seconds. I use a HttpWebRequest to do it, but I don't think that's relevant.The 'problem' is that this request + parsing can take a little bit of time, and even more time if internet is a little bit slow. So, I decided to do it in a background thread.I have a method, let's call it GetXmlInfo(), which does all the hard work. Then, I have a timer that ticks every 5 seconds. Now I have two options for starting the thread.Option 1: creating a new Thread object every time the timer ticks:

vb.net
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick Dim t As New Thread(AddressOf GetXmlInfo) t.Start()End Sub

[code].....

In option 2, when the GetXmlInfo method has not finished yet, no new thread will be created and the GetXmlInfo is 'skipped' for one timer tick (or possibly more). Could this create a sort of "deadlock" (I know it's not really a deadlock), like if the thread never finishes for some reason?

View 4 Replies

Open An External EXE From Within Vb Net Without Hardcoding The Path To The .exe?

Jun 9, 2010

Start("Program.exe")
This does not work
Nor thisSystem.Diagnostics.Process.Start("Program.exe")

Only this works...but I can't use the Drive path..cannot hardcode it.

System.Diagnostics.Process.Start("C:Program FilesX-ProgramProgram.exe")

So how do I start an outside Exe file from within vb net without hardcoding the path.

Vb net 2008

View 9 Replies

Create Many Objects (threads) In Loop?

Jun 17, 2011

threads that watch folders and process files. This works fine, but every time needs change to add a new folder or just change some existing rules I have to go in and change the program. I want to builda front end that storesprocessing infofor each watchfolder. The program would then read the configs and build the threads based on them. I cannot find a way to loop through creating the threads.

View 8 Replies

DB/Reporting :: Connection String Not Hardcoding Passwords In Code

Aug 1, 2011

I've been working with VB6, 2003, 2005 and 2010 and I've always hardcoded my database passwords. Recently we ran into a problem where we would like to change all our db passwords for audit purposes. The problem is passwords for different dbs have been hardcoded in all our programs. How can I create programs going forward without hard coding the passwords in? I think I should be using a config file of some sort, but not sure how or where to start.

View 1 Replies

Update Active Directory Without Hardcoding Username/password

Jan 20, 2011

Currently, users log into a web application with their AD (active directory) credentials which are validated against the AD. Once inside the application, certain users will need to update the AD. When I hardcode a username/password, I am able to update the AD, however when I try to force the object to use the logon credentials or if I don't specify the username/password, it throws an error. Obviously due to security concerns, I do not want to hardcode credentials.

Error - System.DirectoryServices.DirectoryServicesCOMException: An operations error occurred.

Public Shared Sub SetProperty(ByVal de As DirectoryEntry, ByVal propName As String, ByVal propValue As String)
If Not propValue Is Nothing Then

[Code].....

View 1 Replies

Create A Loop That Will Declare And Start Multiple Threads?

May 30, 2011

Basically with the code below I would like to create multiple threads. Let's say user input was the number 100 for the "userVal" variable of type integer. With the first pass of the loop, starting with 1, I would like to[code]...

View 10 Replies

Create Multiple Threads To Improve A Function On Program

Sep 7, 2011

i need to create multiple threads to improve a function on my program. it is a simple thing really but it's slow and if multithreaded it can improve the speed some thousand times. my program uses a dll to check the MX record of an e-mail from a textbox called emails if the mx record is correct then it validates that domain, if not, it sends to an error textbox with that mail my problem is that im reading a lot on multithreading and i dont have an idea how to make something like this: for x=0 to emails.lines.count -1' start a thread that runs my function next if i can limit the number of threads to avoid crashing it would be good.

View 5 Replies

Multithreading - .NET 4.0 Execute Multiple Threads But Threads Are Completed Before Resuming?

Oct 19, 2011

I just had a new, last-minute idea on to take on a task, so I am running to StackExchange for quick help.

What I want to do is execute a series of methods right in a row, each in their own threads. I want the application to wait until all of these threads are completed, after which the program will resume. It also has to use managed threading (thread pool).

What quick examples could you provide to help me along the way? If it's too complex, what things should I know about so that I can Google it on my own?

View 1 Replies

Queue Threads - Spawn A Series Of 'child' Threads From A Loop

Dec 30, 2009

I have a main thread which is designed to be a batch processor - it spawns a series of 'child' threads from a loop (which can vary in terms of the no of items) - see below

[Code]...

However, each of the 'child' threads could take anywhere from milliseconds to about a minute to process - depending on the complexity of each calculation. There may also be a large number of child threads - e.g 100s. Creating large numbers of child threads is not efficient. I therefore want some way to effectively queue each child thread (and cancel if the process is taking too long to complete). Autoevents seems like one way of doing this, but the only examples I can find seem to assume there are two different processes on seperate threads, not one process being repeated.

View 4 Replies

Adjusting/hardcoding Progress Bar Formatting In A ActiveX Control Embedded In HTML?

May 7, 2010

I have a VB.NET (VS2010) Class Library project containing a control. It's exposed as a COM/ActiveX component so it can be embedded within HTML/Internet Explorer.

[Code]...

View 1 Replies

Create A Random Number Generator That Iterates Through A Series Of Number Between An Upper And Lower Bound?

Jun 24, 2010

i wanted to create a random number generator that iterates through a series of number between an upper and lower bound. say between 1 and 100. Basically I want the number generator to pick the numbers randomly and then display them until all 100 numbers are picked without any duplicates. so thats easy I can code that. But what I don't know is how to show those numbers in the order they are generated on a windows form. So i have basically a variable that I will let be changed 100 times (or however many times I want, I don't want their to be a size constraint just using 100 as an example) and each time the number is generated I want it displayed on screen (in a list or something not sure what. Hopefully some type of scrollable list) and each successive number also to be displayed in same format beneath it so that I can see the list in its entirety. What type of form control do i use for that? I could do messagebox.show for each iteration but then user is required to hit ok after each iteration and that would obviously be a bad idea if user selected a large number to work through. Anyways, code isn't exactly necessary just point me in the right direction, i.e.what control (if any) to use.how to format the change in data?

View 7 Replies

.net - Given A Large Number Of Objects, Create Multiple Forms In Designer For Them Or Use Code To Create The Forms?

Dec 29, 2010

If I have a large number of classes, each similar to the other in certain aspects (they all share a common base class, but each does things differently), and I need to create Windows forms for each to allow easy changing of their values through a GUI? Create one matching form for each object in VS' forms designer, Or Use code to create the forms dynamically at runtime.

#2 makes the most sense to me, because a lot of these objects will share very common features of the form, notably "Ok" and "Cancel" buttons. But one object might need to draw a textbox on the form while another might need to draw a combobox. Not to mention, if I want to put icons on the "Ok" and "Cancel" buttons, I'd have to do this for each copy of the form in designer, and that sounds like it could get out of hand quickly.But is drawing forms through code sane? VS' forms designer is pretty sophisticated and designed to make life easier. Am I wise to consider ignoring its functionality and diving into the trench warfare of forms design through code? Or are there examples of automating form creation based on an existing object's properties?

View 1 Replies

Create A Lotto Number Generator?

Dec 13, 2009

I'm trying to create a Lotto Number Generator.

My Form has a 3 numeric up down's 2 for the Range "Min & Max" 1 for the Nuber of Numbers that are supposed to be displayed in my TextBox "Mumber" 1 TextBox"tbNumbers" 2 Buttons The first just generates a single Number in the Range.

Dim SingleNumber As New Random
Dim NumberRange As Integer = SingleNumber.Next(CInt(Min.Value), CInt(Max.Value))
tbNumbers.Text = NumberRange.ToString

[Code].....

View 11 Replies

Create A Number Sequence That Always Forwarding?

Oct 2, 2009

how to create a number sequence that always forwarding.. but back to first number again..

for example:

i have determine that number only 0-9
i give an input the 'start' and 'end number'

[Code].....

View 5 Replies

Create A Serial Key/number For Program?

May 18, 2011

i am making a program in visual basic 2008 and when the program first starts up on acomputer/device i want it to come up with a screen that asks for a serial key. i also only want the serial key (that i give to the person i am giving the program to) to be accepted once.eg. if he copies the program and gives it to another person who takes it home, they have to enter a new one (that i would have to give them). if they enter the same key as person 1, i want to deny access.

View 4 Replies

Create A Serial Number For The Software?

Jun 29, 2009

I would like to create a serial number for the software I created. I need a sample link.

View 7 Replies

Create An Invoice Number Using The Last Two Letters?

Mar 2, 2009

I need to know how to use a function to do the following: Create an invoice number using the last two letters of the last name and the first four digits of the zip code.

Example:

Name: John Doe
Zip: 11111

Invoice number becomes DO1111

View 4 Replies

Create Random Number Generator?

Jul 28, 2009

I need to create a random number genrator to generate a membership number when i open my sign up form. i need it to be shown in a text box.

View 9 Replies

Dim An Integer In Excel To Create New Number

Oct 11, 2009

I'm trying to create a code to open a new workbook..once it's open I want to save it in numbered order. I have everything else in the code complete except how to finish the integer. I know this should be easy but I'm having a total mind block. [code]

View 1 Replies

How To Create Dynamically Number X Of Collection

Feb 16, 2009

I got a blank, how do I create dynamically a number x of collection?

View 7 Replies

How To Create Invoice Number That Increases

Sep 13, 2010

I have a simple question that most could probably answer. I have a button that when it is clicked it transfers information from that form to a microsoft word doc. Now what I want to do is everytime that button is clicked it creates a number that is displayed on the word doc. So this is how it would go:

first click- it would show a number 1 on the invoice.

second click- it would show a number 2 on the invoice.

This would continue as long as the program is used.

View 6 Replies







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