VS 2008 : Have Multiple Threads Input Data Into The Same Arraylist

Dec 20, 2009

I want to have multiple threads input data into the same arraylist, so they would need to share it. If this is possible how can I do this task?

View 1 Replies


ADVERTISEMENT

Have Multiple Threads Run Through An Arraylist Of Object And Process Each Object?

Apr 30, 2009

I am trying to have multiple threads run through an arraylist of object and process each object. My problem is that each thread processes every object in the array.So they are not working together on the job. I made sample application to show my problem. I think the problem is somewhere in my ThreadSub() Here is the

Imports System.Threading
Public Class Form1
Dim myitems As New ArrayList

[code]....

View 2 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

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

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

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

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

VS 2008 Updating SQL Database From Multiple Threads?

Oct 28, 2009

Is it safe to update an SQL database from multiple threads at the same time? I have a method which runs on up to 25 thread pool threads at the same time and it attempts to write to a text file and update an SQL database - I assumed that writing to the file would not work properly if all threads tried to write to it at the same time, so I have used SyncLock for that part of the method. Just wondering if I need to do the same thing for the part of the method that updates the SQL database? or is the framework (or SQL server) smart enough to either execute multiple update statements on the same table at the same time without a problem or queue them?

View 5 Replies

Pass Multiple Parameters To Multiple Threads?

Sep 15, 2011

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

View 1 Replies

VS 2008 ArrayList - Make The Call To Get The Data Out Of The List?

Mar 31, 2009

My application reuses the same data returned from the database throughout the application. For example, a list of airport codes retrieved from the dataabase could be used on 5 different forms. In VB6 I placed the information into a Public Array. I'm looking for the best way to load and make available without hitting the database 5 times. After researching I found arraylist might be the way to go. My problem...I'm not sure I'm doing this correctly and not sure how to make the call to get the data out of the list.

[Code]...

View 4 Replies

VS 2008 - Reading ArrayList In My.Settings And Add Another ArrayList To It

Sep 21, 2010

What I need to do is read an ArrayList in My.Settings and add another ArrayList to it. The first think I'm trying to do is load My.Settings.Records into myArrayList. I'm not quite sure on the proper way to do this. I've tried things such as Dim myArrayList As ArrayList = My.Settings.Records, I'm not sure if I need New and I'm not sure if I need .Clone or .CopyTo.

Then I have another ArrayList myArrayList2. To get this into myArrayList I've done: [Code] Then to save it back to My.Settings I've done. My.Settings.Records = myArrayList. The problem is I keep on getting Object reference not set to an instance of an object error on the AddRange line. My.Settings.Records is definitely an ArrayList and it will sometimes = Nothing. The objects will only ever be strings.

View 19 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

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

VB 2008 Check For Data And Make The Program Stay There Until The Data Is Input?

Aug 3, 2010

I have a program for school project that has input fields for Name, Address, City, State and Zip. I need to error check so that the fields are not empty.I have used If statements that check to see if the fields are empty and shows a message box if they are but if I leave the whole form empty and click the button that activates it, all the if statements go- one by one instead of pausing for the user to input the required data.How do I check for data and make the program stay there until the data is input? I have tried TRY/CATCH but it won't catch this type of error.

this is the

'This program computes customer's bills at the pizza shop for all combinations of
'crusts, toppings, sizes and discounts
Option Strict On
Public Class PizzaForm

[code].....

View 10 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 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

.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

Multiple Controls On Winform Mutliple Threads?

Jul 3, 2010

I've created a news ticker control, which reads from RSS feeds and scrolls the text Horizontally. The plan is to have 3 of these on my Windows form, which will each display their own information.

The control is created as a label, which is populated with the text, and then scrolls right to left using a timer, once the label gets to the end of the text, and disappears of the left side, the rss is re-read, and then the cycle resumes. The problem is that with multiple copies of this controls on my form, once one gets to the end of it's run, all three freeze while the rss is reread, rather than just the control that needs to do it.

Is there a way to run each of these controls independently (threading?)? Or is there a glitch in my code causing this? (below - some elements not included, but it should be fairly obvious what is happening!)

[Code]...

View 7 Replies

Multithreading - Code For Running Multiple Threads?

Apr 17, 2010

How to I run multiple threads in VB.NET? Say I need 2 threads - one that prints 100 numbers in a loop and the second one that asks for the user's name and prints it inside a message box.

View 1 Replies

Running Different Processes In Multiple Threads Without Overlapping

Jan 13, 2012

I have a sub-procedure which I want to run a different process, depending on what is currently running. I thought the easiest way to do this was by using an ArrayList of each of the campaign details & adding an 'Inuse' field to check to see if the Inuse field is set to 0 or 1. The problem that I have is that when running the process it is all happening at once & the integer hasn't been changed before the next thread kicks in so my threads are running the same campaigns. I tried to avoid the problem by adding a Thread.Sleep(100) delay inbetween starting threads but this led to exactly the same problem.

Here's an example of what I am trying to do:
Imports System.Threading
Public Class Form1
Private Campaigns As New ArrayList
Private ProcessRunning As Boolean = False
Friend StopProcess As Boolean = False
[Code] .....

View 2 Replies

Seeking Pattern For Multiple Background Threads

Aug 2, 2010

I'm using the following flavor of threading to create n number of worker threads. These threads all have a bit of latency as they interrogate devices that have strict temporal/physical limits.

[Code]...

I'm looking for a pattern that will let me start the worker threads then wait patiently for completion. Sounds simple ("Just raise an event!") but there seem to be timing landmines. Since the completion EventHandler is single threaded, collisions can occur that destroy the EventHandler data.

Is there a straight forward way for 1 of n threads to report an "I'm done" condition?I've literally got lists of these for c++ but vb.net/CLR is giving me brain freeze.

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