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


ADVERTISEMENT

Function Accessed By Multiple Threads With Parameter Passed By Reference

Apr 29, 2011

I am in vb.net and have a function that will be accessed by multiple threads. Everything inside the function uses local variables. However, each thread will pass in its own dataset by reference. From what I have read the local variables should be no problem, but I think the dataset coming in is a concern. How should I control access / execution of this function to make sure that it is thread safe?

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

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

How To Improve Code To Print On Multiple Pages

Mar 16, 2010

I want to print contents of a ListView, currently I can print on one page only so my question is how do I improve my code to print on multiple pages. I've read little about the HasMorePages property but no idea how to use it in this context. Heres my code:I have a PrintPreviewDialog and Print Document to assist in printing [code] I understand most part of this code but not all so its kinda hard to follow the program flow to make any big changes myself so if possible can someone please comment the code a bit? how printing works in .NET because I only understand parts of it so having trouble joining the pieces together if that makes sense?

View 3 Replies

Asp.net - Improve The Design Of A Page With Multiple Case Statements?

Aug 17, 2011

My page contains: GridView1, GridView2, Button1, Button2, DropDownList1 I bind Gridviews to the table selected in dropdown like this:

Dim results as DataTable
Select Case ddl1.SelectedValue
Case 0

[Code]....

For me it looks like a lot of overhead. How can I improve then design and only specify that I'm working on the following record in dropdown list without specifying the Case condition every time? Should I change my design or leave it like it is?

Update:
RunZero, RunOne, RunTwo, RemoveZero, RemoveOne, RemoveTwo, RemoveThree - Execute six different stored procedures.

View 2 Replies

Create Function With Multiple Outputs?

Dec 8, 2010

Is it possible to create a VB function with multiple outputs. Note: I am not looking for an array containing me three outputs or a variable using delimitters

View 3 Replies

VS 2005 Improve The Look Of Program?

Jan 27, 2011

I'm currently writing a football management game (Australian football) and would like to pretty it up a bit. The match engine simulates each player as a small circle, much like the old Championship Manager games. While I'm fine with this style, I'd like to improve the look. I'm just using the simple graphics tools in VB to draw circles and the oval in the background which they play on. They move around using a timer. It just doesn't look very good. The movement isn't smooth and the circles look jaggy and unprofessional. Given that I'd ultimately like to release this product, I want to make it look a lot better.

What are some 2D graphics engines that I should look at? I don't need fancy animations or anything, just some nice smooth movement and nice looking circles. Doesn't seem like I'm asking for much does it? It'd be also nice if I could add in a chrome-like look or something along those lines.

As for the menus and such, well, they are currently just the boring grey VB style. That's fine for now but, as mentioned earlier, I want to release this game at some point. How can I change all of the menus and such so that this doesn't look like a game made in visual basic...basically. I've seen skins before but I'm not really interested in giving my game some generic style. I want to be able to customize all of it for myself. I just don't know how to! Simply fiddling with the colours and fonts of the default VB controls isn't enough.

View 9 Replies

Pass Multiple Parameters To Multiple Threads?

Sep 15, 2011

I have a loop that creates several threads as such[code]...

View 1 Replies

Improve Speed Of Program - User Inputs Min And Max Values

May 3, 2012

I'm currently trying to improve the speed of my program. Basically the user inputs min and max values for a, b, c, and d and a constant n, and then it tries to find the curve/line in the form a (x/b + c) ^ n + d. However for large ranges (1-100 for a,b,c, and d; total of 100 million values to try), it would take around 100 minutes at the current rate (approx 800k values/minute). I'm wondering whether I can further improve the speed. [Code]

View 6 Replies

.net - Using GDI+ With Multiple Threads?

Apr 18, 2010

it would be best if I just copy and pasted the code (it's very trivial).

Private Sub Main() Handles MyBase.Shown
timer.Interval = 10
timer.Enabled = True
End Sub

[code]....

An exception, "The object is currently in use elsewhere", is raised during the tick event.

View 1 Replies

.net - Simultaneous Threads Only One Seems To Function At A Time?

Mar 17, 2011

Threads a + b, (both are trying to delete files).a gets called first, then b while a is still running.b deletes the file successfully but a doesn't.If I run a on its own, a's file deletes fine.

When I step through the code I can see that a's MultiAttemptFilename gets overwritten with b's.

I don't understand.I have an ajax call pointing to a generic handler which passes the filename along with it.In my handler I have the following code:

[Code]...

View 1 Replies

Create A Delegate And Use The Function In Program Called DoStuff()?

Jan 4, 2012

For a class, I have to create a delegate and use the function in my program called DoStuff(). There is an error tht says "Method 'Public Sub DoStuff(stringVal As String)' does not have a signature compatible with delegate 'Delegate Sub MyDel()'.

[Code]...

View 2 Replies

How To Run Multiple Threads With BackgroundWorker

Jan 13, 2010

I am writing a project in Visual Basic where I need to run several instances of the same method in parallel. I can do this using BackgrooundWorker by having several (4) copies of my code module (modules 1, 2, 3 and 4) with a call to background worker in each. I then have a Main form which invoke the 4 modules which setup 4 simultaneous background threads. Seeing as the code is the same I want to simply invoke the same module 4 times.

However when I do this I get an error from Backgroounworker that it is already busy. As I understand it this means that it is being shared. However, I have specifically instantiated it as "private" (private with events worker as new backgroundworker). I have tried running the same code in a Class instead of a Module but unless I make it public I have no way of invoking it from Main. I need to be able to pass each thread data from main for it to work on and if the class is private I cant invoke it.

View 2 Replies

How To Stop Multiple Threads

Nov 6, 2010

This code will show you how I started multiple threads:

For i As Integer = 0 To 10
Dim MyThread As New System.Threading.Thread(New System.Threading.ThreadStart(AddressOf MySub))
MyThread.Start()
Next

Now I'm trying to stop the threads before closing my application but I don't know how to do that?

View 6 Replies

Run Ffmpeg With Multiple Threads?

Jan 25, 2012

how to convert videos files using vb.net and ffmpeg. But as far as i know we cannot use multiple threads to run same exe file to convert files. Do you know how i can convert multiple videos using one external exe file (ffmpeg)?

I have not tried because my computer time was over. So iam just asking a general doubt whether if we attach it to one process then wouldn't the process get locked? Then can we multi-thread this application or not ?

View 1 Replies

VS 2008 - Multiple Threads - Get Two Value?

Jul 28, 2010

I'm testing here something, but i don't know what's the best way to do this.I have a var that tells the application the number of threads that will be started, inside the thread/function that i call i need to return/get two values i have two sub functions, each one returns an integer.Then in the end i need to sum the values.

Example:
Thread1/Function
SF1 - Returns 2
SF2 - Returns 3

Thread2/Function
SF1 - Returns 1
SF2 - Returns 5

After all threads are over, i get the
SF1Total = 2 + 1 and
SF2Total = 3 + 5.

I'm thinking in using shared vars, and inside the function/subfunctions update the values. It's this a correct way to do it? Other question, the threads are assync, but i need to know when the last one finishes. How do i control this? The order they finish doesn't need to be the order they were called....

View 4 Replies

Create A Multiple Line String In Program?

Jan 15, 2011

Is it possible to create a multiple line string in vb.net?

View 7 Replies

.net - Update From From Multiple Threads Of The Same Class?

May 31, 2012

I have this class and I have a loop that launches multiple threads from the same class. This is all done from the main form.Now I want to update the richtextbox on the main from these classes.I have tried those begininvokes etc etc and nothing worked, no error but no output as well.Here the code for launching the threads :

Private PingObjects(100000) As Account 'Account is the class and login is the sub in it...
PingObjects(I) = New Account
Threads(I) = New Threading.Thread(AddressOf PingObjects(I).login)

[code]....

And to update the rtb, im using MainForm.log.text = "....." Nothing happens, no error.I have tried using the begin invoker method as well.

View 2 Replies

Creating And Aborting Multiple Threads

Sep 28, 2010

To get pass the cross referencing error when running a thread, I use this code

[Code]...

But the AddressOf doesn't accept parameters... So how do I get pass that? Or is there another way to use delegate?

View 6 Replies

Dividing Work Into Multiple Threads?

Aug 10, 2011

I've read a lot of different questions on SO about multithreaded applications and how to split work up between them, but none really seem to fit what I need for this. Here's how my program currently basically works:

Module Module1
'string X declared out here
Sub Main()

[Code]....

This is only a rough outline of what actually happens in my code by the way.

My problem being that if multiple threads start running Main2(), they're dealing with the same X value as in the other threads. The loop inside of main2 executes multiple times per millisecond, so I can't just stagger the loops. There is often duplication of work done.

How can I properly divide up the work so that the two threads running simultaneously never have the same work to run?

View 3 Replies

Implement Multiple Threads In Application

May 12, 2010

I need help to implement multiple threads in application.Assume ds.table(0) has 5 and sometime 6 rows rows for i=0 to ds.tables(0).rows.count-1.I have to apply multiple threads, means all five/six rows should start at once using thead and "Process 1" .."Process 4" should also handled by threads.This is hierarchy that I have to apply with threads, how can I do it. It is requested to put piece of code so I can understand better.

View 13 Replies

Sharing Data Between Multiple Threads?

Jul 7, 2011

I know a little about threading and delegates, as well as socket programming. I'm working with a VB.NET-compatible SDK called TrueVision3D to create a small online game for me and my friends. The problem is that I cannot for the life of me figure out how to pass data from one thread to another. I've created 2 seperate threads on seperate forms.

The first thread is created on a form titled FrmLogin, and it contains all the socket code. I need to be able to update variables in the second thread, which mainly consists of a render loop. The second thread is created on a form titled FrmMain. I'm not quite sure if it matters what forms the threads are created on, I'm just trying to give as much information about the issue as I can. I've tried using delegates and events to pass information from the thread back to the form it was created on, which works fine, but how do I pass data to the second thread from the first?

View 1 Replies

Sharing Object Over Multiple Threads?

Aug 4, 2010

I have an application that needs to perform a series of different actions at specific points in time.To do this I have a timer with various actions that occur in its tick event.One possible action is to send out a few messages via a serial port and then wait (between 1- 300 mins typically) for the next timer tick.Another possible action is to continuously toggle one of the control lines on the serial port until the next tick (again 1-300 mins).

In most instances, i'm happy for everything to run on the main thread, but in the case of toggling the line endlessly, I thought it better to give it its own thread.My problem is that for the new thread to use the Serial Port, it must open the port. Likewise, it must close it before the main thread can have it back.

Here are 2 code snippets

Private Sub activityTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles activityTimer.Tick
Dim some variables here
activityTimer.Stop()
If speedThread.ThreadState = ThreadState.Running Then

[code]....

View 4 Replies

Using Multiple Threads For Faster Execution?

Jan 27, 2012

I have a map image with data associated with the map indicated by RGB index. The data has been populated into an MS Access database. I imported the information in the database into my program as an array and sorted them to go in the order I want the program to run.

I want the program to find the nearest pixel that has a different color from the incumbent pixel being compared. (Colors are stored as string attributes of object Pixel)

First question: Should I use integers to represent my colors instead of string? Would this make the comparison function run significantly faster?

In order to find the nearest pixel of different color, the program begins with all 8 adjacent pixels around the incumbent. If a nonMatch is not found, it then continues onto the next "degree", and in this fashion, it spirals out from the incumbent pixel until it hits a nonMatch. When found, the color of the nonMatch is saved as an attribute of incumbent. After I find the nonMatch for each of the Pixels, the data is re-inserted into the database

The program accomplishes what I want in the manner I've written it, but it is very very slow. After 24 hours, I am only about 3% through with execution.

Question Two: Does my program behavior sound about right? Is this algorithm you would use if you had to accomplish this task?

Question Three: Would it be appropriate for me to use threads in order to finish execution of the program faster? How exactly does that work?

Question Four: Would it be more "intelligent" for my program to find the nonMatch for each pixel and insert it into the database immediately after finding it? (I'm making a guess that this would be good in multi-threading, because while one record is accessing the database (to insert), another record is accessing the array of pixels (shared global variable in program).

Question Five: If threading is a good idea, I'm guessing I would split the records up into more manageable chunks (i.e. quarters), and have each thread run the same functions for their specified number of records? Am I close at all?

View 3 Replies

VS 2008 Multiple Threads Ending?

Jul 29, 2010

In the same line of this thread Now i have a problem with the control of the ending threads. This is my

vb.net threadsEnded = 0 For j As Integer = 0 To numThreads - 1

[Code]...

Some times the application doesn't finish and if i pause the application i see that the threadEnded var doesn't have the correct value, seems like some thread doesn't update the value of the var.

View 5 Replies

VS 2008 Shared Sub And Multiple Threads?

Sep 4, 2010

I have a created a class, which contains a sub routine.This sub routine, should ideally be accessable by objects which are not members of the class, so I would like to make the sub, a 'shared sub' (call it Sub1).

Question: I am using many threads and there will be possibly 100s of 1000s of threads all wanting to use Sub1 (which is at present, is not shared).At present Sub1 , is not a shared sub, so every time a thread wishes to use Sub1 , I am creating a (dummy) instance of the class and then applying Sub1, to that instance.

My program works flawlessly using the above technique.Question: If I were to turn Sub1 (which is not currently shared) into a shared sub, and directly had various threads calling Sub1, would there be any issues with locking, ie. would it possible for 2 threads to enter that thread and start overwriting variables, which another thread has written to?

NOTE: there are no shared variables/properties in Sub1 and all variables used in Sub1 are declared within the sub itself.

View 7 Replies

.net 2.0 Multiple Programs Each Running Threads On Xp, Will .net 2010 Be Better?

Oct 2, 2010

In the past few weeks, to speed up our database freshening process, I've created a couple of extra programs, basically copies of the exe file. The program itself, accesses web pages, images etc and uses threads to do so. The second program uses LIMIT 300,100 and the third LIMIT 600,100, to make sure they don't work on the same records.

Before the last few weeks, one occurrence of the program used to run without problem, from the task scheduler all through the day. Only one occurrence of each exe can run at a time.Since theres now three programs running, .net 2.0, on xp, the program often seems to get stuck and never ends. I have to kill it from task manager.

It runs fine in the IDE I just wonder if there would be any benefit from upgrading to vb.net 2010 ?

View 1 Replies

Can Share Data And Methods With Multiple Threads

Jun 15, 2010

I've used mutiple threads in a VB.NET program but I don't know if I did it right.I would like to start about 3 threads.Can they all use the same methods?Will a separate instance of each method automatically be created for each thread?If not, how do you make sure that the data within the method that is used by one thread is not used by another thread?I would like some data to be shared by all threads.How is data shared among threads?What is the protocol for changing the data and checking for changed data?Is there a good tutorial / website that explains how to handle methods and data when using multiple threads?

View 3 Replies

Get Multiple Threads To Store Data In One Array?

Sep 4, 2009

I have a application that use threadpool, and each thread stores data in the same textfile. I now want to have each thread store the data in the same array instead and use a timer to store all current data in the array into the text file after every couple of minutes.

So what I want to do is:

1. All threads store data in one array that they all have access to

2. After every couple of minutes the data in the array is stored into the text file.

I know number 2 can be done with a timer, but is the first one possible? If so how do I accomplish this task?

View 6 Replies







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