VB - Using Nested Mutex's In A Threaded Application?

Nov 17, 2010

I have a mutex and threaded related question about = Run one or the other per call to routine

[Code]...

View 2 Replies


ADVERTISEMENT

Changing A Control's Properties In A Threaded VB Application?

May 11, 2011

I am running into an issue with changing properties of controls on a VB.net project that I am working on. The portion of code that I am having trouble with is re-enabling a couple of buttons and a ComboBox after a Threaded operation completes. The point of it is to disable the buttons after clicking the main "run process" type of button (called cmdCrawlSearch) so that the process can run on a new thread while the form is updated with the status. I was able to learn about Thread Safe calls using delegates in order to update the Text property of the TextBox (txtOutput) on the form, and thought that enabling buttons would be just as easy, but when I am trying, I am either getting an "Object reference not set to an instance of an object" exception, or an "Exception has been thrown by the target of an invocation" exception (from the current version of code) with the InnerException being the Object reference exception. I am posting the portions of code related to the issue, then below it is the InnerException name and stack trace. Perhaps I am not using the Delegates correctly (since I still do not fully understand what can and can't be done using a Delegate.) Or there is a better way to do this.

[code]...

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

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

How To Check If Mutex Is Released

Dec 23, 2009

i've got a Set and a Get in a property. I want to allow multiple threads to do Get anytime they wish to, however if any thread tries to do Set, all threads must not be able to Get/Set until the Set is complete.[code]the problem is that this is pretty inefficient because each request to Get will steal the Mutex and prevent other Gets until the stolen Mutex is Released. Is there anyway to just check if a Mutex is released instead of using WaitOne because WaitOne checks and gains control of the Mutex which is not what i want

View 29 Replies

Using Mutex Faster Then Semaphore?

Aug 10, 2011

My application is very very speed esential and even a microsecond matters.I am using semaphore(1,1) at varios places. I think it can be easily converted into mutex.But I want to know if it will be advantageous or its one and the same thing as far as speed is concerned.

View 1 Replies

.net - Single Instance Check Using Mutex?

Oct 26, 2011

I'm trying to implement single instance application using mutex.the application can run only one instance from a given directory.i tried to implement it in Applicationsevents class but it's not working.I replicated it with a test harness with a single form.my ApplicationEvents.vb code:

Private Sub SingleInstanceCheck(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
Dim strLoc As String = Assembly.GetExecutingAssembly().Location

[code]....

it runs multiple instances.Things I am not able change:

1.project setting has "Enable Application framework" ticked

2. ApplicationEvents.vb handles UnhandleException which means i cant have a module as startup.

View 1 Replies

Find A Combobox From Another Application In Nested Form?

Apr 29, 2009

I want to be able to read the combo box and select it from my own app. How do I go about? Is this the correct procedure?

windowsformswindowappa = FindWindow("windowsforms10.window.8.app.0.378734a", "DTE Production - DTE Processing Facility")
windowsformswindowappa = FindWindowEx(windowsformswindowappa, 0&,

[Code].....

View 3 Replies

Testing The State Of A Mutex Without Calling WaitOne

May 4, 2011

Is there a way to do a read-only test of the blocking state of a mutex? Currently I use the return value of WaitOne(0,False). This works fine, provided that if the return is true, I also call ReleaseMutex. Failing to do this, my test would corrupt the state of the mutex. So, the test is effective, but it has the irritating side effect of two state changes in the mutex. In addition, WaitOne and ReleaseMutex can throw exceptions and that further complicates matters. If WaitOne is successful and returns true, and if ReleaseMutex throws an exception, I can't clean up the mess that I have made.

View 17 Replies

Loop And Enumerate Properties Of Nested Classes In Nested Classes?

Sep 24, 2010

so far i got

code
For Each item As Reflection.FieldInfo In GetType(NameSpace.ClassWithNestedClasses).GetFields
rtfAppend(item.Name & ":" & Tab & item.GetValue(Me))
Next
For Each item As Reflection.PropertyInfo In GetType(NameSpace.ClassWithNestedClasses).GetProperties()

[code]...

which gets me the simple string vars and properties of my top class, but how can i apply this to loop through all sub classes and get there vars and props?

View 1 Replies

Accessing A Threaded Form?

Apr 11, 2011

i created a threaded form class that i call when i know an update is going to take a while....it is a simple form with a label and an animated marquee progress control. the code is listed at the bottom....whenever i try to set the message, it says i cant do it with error "{System.InvalidOperationException: Cross-thread operation not valid: Control 'MessageLabel' accessed from a thread other than the thread it was created on." from my form (in my SAVE function, i put the following line:[code]....

View 6 Replies

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

Threaded Webclient Still Slow?

Nov 24, 2008

Here is my webclient class that I am using to check multiple web sites at the same time. I am threading the class so each thread is creating a new getHtml Class. It seems that it still is waiting on something, because it only returns about 2 pages per second, which is great, but I think it should return faster if they are truly running on separate threads.When i made a similar perl script it would return 50 pages in about 10 seconds so it was much faster than this webclient method, unfortunately I don't want a cli. Let me know what you think. I have tried setting the proxy to null, but that didn't do anything.

Class getHtml
Friend result
Public Sub GetPage(ByVal URL As String)

[code].....

View 4 Replies

VS 2008 Server Threaded App?

Apr 25, 2012

I beleive I have asked a question similar in the past but I am re-visiting it with a slight difference and wonder if anyone can give advice.I am building a server app that when starts it opens a second 'listener' thread that when started will open up a listener on a port and wait. When a client connects it handles it and upon disconnects starts from the top and waits for the next client. Also once a client has connected its job is to look at a list of ports see what is free quickly respond with a port number setup another thread which then listens on the port number for the client.

At pretty much all times the 2nd thread will be stuck on a line waiting for a connection and at any one time there maybe more threads running waiting for a client to connect and if a client connects it never ends the thread as its stuck on a line of code.

Now currently if the service gets a request to stop it cannot stop the threads because they are just waiting on one line of code for a client to connect. I can easily set a varible to indicate the service is closing but they can only check that once a client is connected so the code is run.

What I either want is:

a) a way of force closing a thread from the main app thread or

b) a way for the line of code waiting for a client to connect to timeout after a certain amount of time.

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

.net - Threaded Image-scaling Sub Still Bogs Down UI

Apr 30, 2009

I created an image-viewing control for my boss that incorporates panning, zooming via the mouse wheel, and drawing a box to zoom to. The control needs to support very large image files (i.e. several thousand pixels on each side).

It all works, but whenever the code is scaling the image the control UI becomes unresponsive. My boss had me use threading to set the scaling code apart from the UI. The scaling code is now definitely on a separate thread but the UI is still bogged down while scaling code is running!

View 4 Replies

How To Make Activator.CreateInstance Threaded

Nov 5, 2011

I have some code that runs within a multithreaded class.Basically i create many threads which contain instance of this class.Within this class i create an object to either a vb6 or .net dll using reflection, then i call a method within that object. The object that gets called can be different every time.But for some reason even through i have multiple threads going when i get to the Activator.CreateInstance it is no longer multithreaded. I want to catch the error returned and put it in a log.

If UCase(pRow("TypeVB6").ToString()) = "TRUE" Then
classType = Type.GetTypeFromProgID(ClasstoInstantiate, True)
Else

[code]....

View 1 Replies

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

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

Pass A Variable To A Threaded Procedure?

Mar 4, 2010

How do I pass a variable to a threaded procedure? The clickedItem.Tag contains a username as a string which I want to pass to Public Sub GetLockoutInfo(ByVal UserID As String) but the AddressOf GetLockoutInfo line doesn't allow for a parameter to be passed to the procedure.

Private Sub CallGetLockoutStatus(ByVal sender As Object, ByVal e As System.EventArgs)
Dim SearchUserDetails As New NiRDs_Functions_OC

[Code].....

View 2 Replies

Threaded Process Not Running Properly

May 18, 2011

I am firing a threaded process using (checkfile is my sub):


mythread =
New System.Threading.Thread(AddressOf
checkfile)
mythread.Start()

THe problem is that it doesn't seem to be working the way I anticipated. Whilst the process is actually being run in the background, the main UI is just frozen. This is highlighted by the gif animation i wanted to have animating (eg. like a ticker) whilst processing, actually coming up as a static image. As soon as I click anwhere on the UI i get the "Not Responding" message at the top, plus the button that executes the thread still seems to be depressed and has the orange glow around it.

View 5 Replies

VS 2010 - Add ArrayList To Threaded Listbox

Nov 3, 2011

Add an ArrayList To Threaded Listbox i have been working on this for ages and cant get it to work. here is what i have so far... this gets dup sub to work in new thread when i click button2 the dup sub will filter through Listbox2 items and sort through the listbox and if it isnt a duplicate it will add the line to an arraylist i now need to the array list (decleared as arr) to go into listbox2 in short i need to make this line of code work as a crossthreaded call

[Code]....

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

.net Simple Threaded GUI Based Program - Where To Put The Thread

Oct 12, 2009

I have written a small GUI based vb.net program that speaks to embedded devices via the com port. The GUI code contains a class which all communication to the embedded device is handled through (com port device, communication protocol, parsing info, holding device related info after each read).That class is called EDComms.

I wanted to add a thread so that the EDComms object could run in the background and report back as it downloads logs files and such (It can take a while to get log files from the device sometimes).So. Should I have EDComms inherit from backgroundworker thread? Or should I have a background worker thread as a member of EDComms?Right now I am going with the second choice. The only thing I have to do now is write a func for registering two delegates from the GUI for notifying task progress, and notifying task complete.Or is there a better choice than these two I have presented Perhaps have the thread as a member of the GUI?

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

Cross-thread Exception When Coding Single Threaded?

Jun 5, 2011

I'm having a small issue; I start a process and when that process exits, I raise an event which removes a control from my form.It all works perfectly until the part where I want to remove a control from my form. Visual Studio gives me a cross-thread exception even though I'm programming single threaded.

View 6 Replies







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