Multi-threaded Code Examples?

Aug 10, 2011

I'm trying to teach myself how to create multi-threaded applications in Visual Basic Express 2008. I found a page headed "Creating Threads and Passing Data at Start Time" in the Library here -

[url]

However, I can't get any of the examples on that page to run. I pasted the code from an example into a new Project in my IDE but pressing F5 just gives me build errors which I have no idea how to resolve. It's probably something trivial but I can't progress with these examples. Please can somebody tell me what I need to add to get them to run

View 1 Replies


ADVERTISEMENT

Run A Multi-threaded Console App

Jul 21, 2011

I'm trying to run a multi-threaded console app in VB and am having thread cross-over. Basically I want to run 5 threads, have them continually access a queue, process, and repeat until there's nothing left. When all threads have processed I want them to do something else.I'm attempting to use SyncLock to prevent multiple threads from accessing but it does not seem to be working.[code]

View 3 Replies

Wpf - Multi-threaded ObservableCollection In VB

Jul 14, 2010

This is my attempt to create a ObservableCollection in VB that is WPF thread-safe. Can you think of any problems it may have?

[Code]...

View 2 Replies

Multi-Threaded Drawing Images In A Row

Apr 5, 2011

I am drawing five images in a row. The five are the same thing at five different zoom levels. Therefore, only one of the five will be displayed at any one time, but the others have to be there because there can be over 100 images being displayed on the screen at any one time, and each drawing is quite complicated. If I were to draw them all on the fly, then zooming would require that all 115 images be recreated and redrawn with each zoom. That's painful. To avoid that, I draw all five zoom levels of each image. When the user iteracts with the form, they will be interacting with, at most, two of the images, so when they interact with the form, only two of the 115 have to be redrawn, though those two have to have all five zoom levels drawn, for a total of 10 images.

[Code].....

View 14 Replies

Multi-threaded Task Under Windows

Nov 11, 2010

I've just completed my first multi-threaded task under windows. Historically I am a VMS Engineer. You could multithread in drivers in VMS but VMS never had formalized threads. Which means it never had applications threads. Threads will become increasing important in the future. I thought this maybe a good time to discuss them. Not having access to sources hurts in terms of the amount of depth one can achieve in Windows. Some of the topics for this thread might be...compute resource regulation, how to do multi-threading and of course things to watch out for.

View 1 Replies

Oracle Database - Multi Threaded Implementation?

Mar 12, 2011

I have written a rather complex dll for processing a large volume of data (~4,000,000 records) from an Oracle database. It works well, but takes about 23 hours to run.Since I wrote the code fairly compartmentalized I realized that there are 6 routines that should be able to run concurrently, and I have a multi core processor,I decided to try my first multi-threaded implementation.

In the routine I am working on I am doing no I/O everything is in memory in variables. My data is already in dataTables and hashTables. Most of the data is defined as private in the class scope, but no conflicting updates should happen because the code segments works very distinct portions of the dataTables.The concept is simple, I have 2 routines that need to complete before launching my threads, and one routine that needs to run after all of the threads have completed. Here is what I am trying;

ProcessDXDate()
ProcessHistology()
aryThreads(0) = New Threading.Thread(AddressOf ProcessLaterality)[code].....

View 7 Replies

.NET - Multi-threaded Iteration Over A Single List (Of T)?

Oct 22, 2009

I'm using VB.NET. I want to build a large List (Of MyClassOrStructure) that becomes static after its initial population.I'm going to have multiple threads that need to iterate through this list to read data (no writing, inserting, or deleting)

Are there any very bad things that I need to keep an eye out for?

View 3 Replies

Create A Multi-threaded Proxy Checker

Feb 1, 2011

I am trying to create a proxy checker. This is my first attempt at multithreading and it's not going so well, the threads seem to be waiting for one to complete before initializing the next.

[Code]...

View 2 Replies

Raising Events In Multi-threaded Classes?

Aug 27, 2009

Raising events in multithreaded classes?

I am running a class(gamepad handler) that uses many child threads to check for key input and the like then it raises events to my form to sort out the needed reaction, Is there a way to make the event raises on the same thread as the class itself.

View 3 Replies

VS 2008 Multi-threaded TCP Server / Client?

Nov 14, 2009

I'm having some trouble creating a multi-client server / client thingy.So far, I've used Atheist's example and allowed the clients to successfully transmit information.However, whenever I send more than 1 message to the server at the same time, the server bugs up and does not receive the message at all. I suspect it has something to do with the DoRead method reading from both clients and stuffing it up or something.

View 13 Replies

Re-write Application To Be Multi-threaded Using The Background Worker?

Jul 23, 2009

how to re-write my application (http:[url]....) to be multi-threaded using the background worker. The use case is something like:

1. User opens a binary file, it can be several Gbytes in size so reading it into memory isn't practical.

2. User can then navigate through the file in 188byte chunks, data is read from disk, decoded, and displayed for each chunk in turn.

3. User may want to search for some data or build a report. This will involve repeating the read, decode, display, function multiple times. During this looping the GUI stops responding and there is no option to cancel so I want to make it multi-threaded. So, is it safe to open the file in the GUI thread and then read from the file in the background thread? I currently use something like this to open the file once:

Dim fi As New FileInfo(filepath)
fs = fi.OpenRead()
and then in a separate sub multiple calls to:[code]..........

View 4 Replies

VS 2010 Multi-threaded But Using A Global COLLECTION Of Objects?

Mar 19, 2012

I've got a multi-threaded app - that is using a global COLLECTION of objects.I'm starting to think that objects - when copied to objects - are really just reference pointers to the "single object" in memory - as they would be in JAVASCRIPT (too many languages At any rate - this code - when taking the object from the collection to work with is it making a new object to play with or is it working the single object that actually resides in the collection?

[Code]...

View 16 Replies

.NET Multi-threaded Variable Access - (GUI, Controller, Producer, Consumer)

Jul 25, 2009

I have an application with 4 threads. (GUI, Controller, Producer, Consumer) The GUI is self-explanatory. The controller starts the producer and consumer threads after some intial setup. The producer creates items and places them in a free slot in a "ring buffer". The consumer takes items from the "ring buffer" and writes them to disk. The producer creates items at a much higher rate than the consumer. The consumer is IO heavy and IO bound. Currently I am checking a variable in each ring buffer slot to determine if it can be written to.

if Slot.Free then
Write Slot.Data To Disk
end if

I am not using lock/synclock instead I'm just reading / writing the value of the slot's "free" variable. I don't believe that is correct even though it is a volatile read/write. Is there a better method to read/write this variable? The variable is of type "integer" and is either 0 or 1.

View 5 Replies

Coding - Threads Vs. Tasks - Writing Multi-threaded Applications

Oct 1, 2011

I've been writing multi-threaded applications for a couple of years and have started reading about the Task class. It looks like it handles mutex and synchronous/asynchronous threading in an easier to follow fashion. I was just wondering if you the community likes writing threads the old way or the 4.0 tasking applications. Lastly, I thought multi-threading was parallel computing. But I was reading that there are special task etc. parallel functions.

View 2 Replies

C# - Catch Events In Multi-threaded Application That Can Be Watched By Main Thread?

Dec 4, 2009

I have a console application (VB.NET). When it is started, it spawns worker threads to find work in the database and do the task, then look for the next task (A workflow basically).

The problem that I have is that I have my Event Handler in the main thread that spawns the worker threads. Those workers, if they error, raise an event to a public delegate. However my main thread is not detecting these events, and I cannot figure out how to make it. My intention is to do all logging (text/database), email alerts, and restarting the worker to find another task that is not errored. (This will be expanded in the LogErrorMessage routine and such, for now I am just keeping it a simple Console.Writeline so that I can see if the method is being fired or not)

Here is the code around what I am trying to do:

Logger Class:

Public Delegate Sub LogDelegateError(ByVal Ex As Exception)
Public Class EventLogger
Public Event EventError As LogDelegateError

[Code].....

View 2 Replies

Make Label Visible On Main Form From A Multi Threaded Process

May 17, 2011

I am usng a multi threaded process to fire off a task, but when it is completed I want to make a label visible on the main form (form 1), eg "process completed", however the code I have in place comes up with the following error message;

Cross-thread operation not valid: Control 'lblCompleted' accessed from a thread other than the thread it was created on.

View 4 Replies

System.DirectoryServices Pegs Processor When Multi-threaded - Can I Lower The Burden?

Feb 23, 2009

My application takes the currently logged-in user and uses an a DirectoryServices.DirectorySearcher to pull a few additional detail about them (some properties we have stored in a few custom AD fields, as well as their email address). This works great, though I've always though it was a little slow - my single-threaded code could only make about 2-3 requests/second to AD.

The real problem came when I moved this code to a web server. With multiple simultaneous users, the number of requests/second jumps greatly, and the LSASS.EXE process pegs on my server. I've checked the domain controllers, and they're just fine - the bottleneck is clearly on the application side. I suspect that what's slowing my down is the NTLM/Kerberos challenge/response, and the number of simultaneous requests pegs even the multi-core processor.

Our network policy doesn't allow anonymous reads from AD, so that choice is out. Also, I've tried every member of "AuthenticationTypes" (in the example, I'm using .FastBind), but they all seem to have about the same throughput rate with the same load on the processor.how I might work around this restriction and lower my demands on the processor? Here is the code I'm using - pretty straightforward:

Dim sPath As String = "LDAP://" & stringUserDN
Dim entry As New DirectoryEntry(sPath)
entry.AuthenticationType = AuthenticationTypes.FastBind[code]......

View 1 Replies

Office Automation :: Multi-threaded Real-time Data Handling In Excel With COM

Jun 22, 2010

I have an Excel based algo-trading app that needs to take in lots of real-time data, and make trading decisions based on the calculations driven by the data. It is not one of those "read-only" stock ticker kinda spreadsheets.I created a COM object with VB.NET that runs in its own thread space which collects data from a socket, and when the data is read it raises an Event with data attached. In Excel VBA, the event handler parses the data, puts them to the right places on the spreadsheet to feed calculations (so far it sounds like a stock ticker app), and then, based on the results of the various calculations it does something.The problem is that when the user starts to click around the spreadsheet while there is large amount of data coming, the event handler's cell updating breaks apart. If the app is left alone without user action, it stands well. My frustration comes from not understanding what happens to the main thread when a user clicks around. Either the event handler blocks the user action, or the user action blocks the event handler (under which case I will put in some queuing facility). But I just don't see how user action can break the code (like causing VBA to stop executing)

View 9 Replies

Sending Multi-threaded SendEmail Request Returns General Mapi Failure

Mar 5, 2009

I'm using the MAPI code by Dave Brooks.I am attempting to programatically send out a Crystal Report that is generated.When I run through the code without threading everything runs fine. The problem is when I use threading I get the return error "General MAPI failure [2]".I have never used threading before and understand that there are dangers involved. Can anyone provide any insight into this issue? NOTE: I've removed exception handling to make the code clearer.[code]

View 1 Replies

Looking For Examples Of Error Handling Code

Sep 14, 2009

I have a routine that is called when an unhandled exception occures.It is called by the MyApplication_UnhandledException method in applicationEvents (which handles Me.UnhandledException)

I am looking for some code that manages disects the data provided to generate information that is of benefit to the debugging team.

View 16 Replies

What Exactly Is The "Multi-threaded Debug DLL" Runtime Library Option Doing In VS 2008

Mar 29, 2010

I have a solution in VS 2008 that creates a DLL. I then use that DLL in another application. If I go in to the DLL projects property pages and change the following configuration for a DEBUG build then the built dll no long provides the desired functionality. If I change it back and rebuild the DLL, then the DLL does provide the correct functionality:

[Code]...

View 3 Replies

VB Using Multi Code Files?

Mar 20, 2011

I m trying to use multi code file that contains events, functions etc...I have a form that named Form1.vb, code file Tab1Codes.vb and a class ClassUsers.vb.Form1 is containing a function like:

Public Sub Tab1ShowHideFunction()
'some codes....
End Sub

View 2 Replies

Code A Simple Multi-User Chat?

Apr 10, 2010

I've created an application, And now need to add the chat feature. It just needs to be basic, But im un sure on how to code one since i am still a beginner at Visual Basic. I know there is a way via TCP Listener using Net.Sockets, But im stuck there. I am totally out of my mind when i think ill know how to code. But here is how the chat will work[code]...

Server side, Is just to host it. I will host it on a windows vps with ports opened, and Anyone who downloads the program can connect to the chat. The username or Nickname of the user will come from 'My.Settings.username'. At this point I am willing to pay someone to code this project.

View 2 Replies

VS 2008 - Multi Threading - Error Code

Oct 11, 2011

Wheres my error on this code...

Imports System.Net
Imports System.Threading
Public Class Form1

[CODE]...........

Basically what I want to do is that User will select how many thread w/c is the PickThread.value, then it will do the stuff.

View 11 Replies

VS 2008 [Multi-threading] How To Run This Code In A Separate Thread

Apr 21, 2009

I am creating an IDE for a game script with similar functionality as the Visual Studio IDE (at least, some of it). The game script consist of code that looks visually a bit like C code. It uses braces to define the start and end of a 'class' and uses nested braces to define the start and end of an 'event' in a class.

What I want finally is to have two Comboboxes above the text editor, one that lists each Class and the other listing each Event. The comboboxes should also show the Class and Event that the caret is currently in, just like in Visual Studio.I have attached an example of such a script (you can open it with Notepad).However, here is a short example where you can also see how I "defined" classes and events:

class1
{
event1
{

[code]....

As you can see, the classes are the 'names' of each block of code, defined by matching braces { }. The events are the names of each nested block of code, also defined by matching braces { } but inside a class. There is only one level of nesting.As you can also see, the layout can follow the standard C-style layout, or a slightly different layout (using the opening brace on the same line as the class/event name), or even a completely chaotic mess. As long as the braces match correctly, the code is valid.So in short, the large blocks are classes, while the nested blocks are events.

What I want to do, is parse an entire script, and store all the Classes (and eventually, also all the Events, but let's forget about them for now). I want to store the Class name, start position (defined as the start index of the name), end position (defined as the index of the closing brace) and the full text (defined as the text between start and end position, so including the name).

vb.net
Public Class clsClass
Private _Name As String

[code]....

The code works basically by finding every first opening brace (the opening brace of each CLASS, not event), and then loops through the class (using a brace counter to keep track of the nested braces) until it found the last closing brace. It then stores the name, start, end and fulltext in a new clsClass and adds it to the list to return.

View 3 Replies

VS 2008 - Multi-Threading - Code That Will Need To Be Repeated But With A Chance Of It Overlapping

Jul 29, 2009

Multi-Threading. I have got a simple bit of code that will need to be repeated but with a chance of it overlapping the only complex bit is there will be a varible that will be different each time. so I was wondering if I put it in another Thread and store the varible within the thread code would that achieve what I am looking for? To make it slightly easyier once the thread is started and pulled the Varible in there will be no cross talking between the thread and main app thread (ie no progress reports, no aborts/suspends etc) Nothing will be feeding back on thread completion either, when it ends it ends.

This is what I have so far:

Imports System.IO
Imports System.Threading

[CODE]...........................

View 5 Replies

WPF & MVVM: Any Examples Using VB?

Sep 26, 2009

Almost every example of MVVM I found is coded in C#, are there any examples/tutorials coded in VB.Net? I'm having a hard time translating C# to VB.Net since I haven't really used C# in any meaningful way...Also, does a MVVM Template/Toolkit for VB.Net exist yet?

View 4 Replies

Multi-Dimensional Arrays - Code To Set Array Values And Store Them In A Variable

Aug 7, 2010

I have this code to set array values and store them in a variable,

Dim productName As String()
Dim productPrice As String()
Dim productCategory As String()

[CODE]...

How do you get the variable values to output like this?

<input type="text" value="Chang Beverages $19.00" id="Chang" /><br />
<input type="text" value="Ipoh Coffee Beverages $46.00" id="Ipoh Coffee" /><br />
<input type="text" value="Gula Malacca Condiments $19.45" id="Gula Malacca" /><br />

View 2 Replies

Multi-threading Mechanisms To Run Some Lengthy Operations From Winforms Code And Communication With GUI

Mar 16, 2010

What do I want to achieve: I want to perform some time consuming operations from my MDI winforms application (C# - .NET). An MDI child form may create the thread with the operation, which may take long time (from 0.1 seconds, to even half hour) to complete. In the meantime I want the UI to respond to user actions, including manipulation of data in some other MDI child form. When the operation completes, the thread should notify the MDI child that the calculations are done,so that the MDI child can perform the post-processing.Should I use explicit threading (i.e., create explicit threads), thread pools? Or simply just propose your solution. Should I create foreground or background threads?And how does the thread communicates with the GUI, according the solution you propose?

View 7 Replies

PC Audit Software Examples?

Nov 16, 2009

Are there any examples of PC Audit software or tutorials/code? While I found 80% of my questions on this forum, like how to retrieve ram info, how to retrieve hard drive space, etc..

View 1 Replies







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