I have an application that performs a lot of busy work. All of the work is performed using a BackgroundWorker and the point of execution is the DoWork Event of the BackgroundWorker.On the UI thread, before the workload begins, I display a PictureBox that contains an animated GIF that illustrates progress; for the most part this works fine and the UI thread is not paused or slowed while the BackgroundWorker does its job. There is however, one instance where the UI thread is impacted by the work being done and it defeats the whole purpose of putting this work in a separate thread. In this application, the user must wait until the work completes before they can move to the next step, so my sole reason for moving this all to a BackgroundWorker was so that I could display a smooth, uninterrupted progress indicator on the UI thread while this work was being done, so that the user could see that something was happening.
The case where the work being done is impacting the UI thread (pausing/delaying the PictureBox animation) deals with a referenced COM object.
[Code]...
All of the COM object event handlers and subsequent functions are appropriately using Delegates, but I am not sure why the ProcessFiles method would cause the UI thread to hang while the work completes; I thought that was the whole purpose of the BackgroundWorker.
Quote:Handles clause requires a WithEvents variable defined in the containing type or one of its base types.
That error is on both of these, in blue
Private Sub SpellChecker1_DeletedWord(ByVal sender As Object, ByVal e As NetSpell.SpellChecker.SpellingEventArgs) Handles SpellChecker1.DeletedWord 'save existing selecting
[code]....
I have added the reference, I have also added them to the toolbox. My dictionary is all set. What did I miss?
I have a problem. I'm creating a new thread, which should do some stuff and update a text box. But, when I test my program, the main (UI) thread is doing all the job, even though I declared and started a new thread.
[Code]...
I even made another thread for testing purposes, but it was the same.
I've been raking my brain for quite some time on this. Is there any way with VB.NET that I can use multiple IP's in one instance of a program? For example, I want to be able to navigate to a web page 10 times at once, with each one using a different IP. I want them to be parallel (multi-threaded) rather than going sequentially. Going sequentially, I could just do the action, change the IP, do the action, change the IP.
I have a button and when it's clicked a HTTP request is sent out to a website to do a few things, but because its got to load the external resources it makes the interface frozen. I've moved the HTTP onto another thread using the follow
VB.NET Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim Thread1 As New System.Threading.Thread(AddressOf check_accounts)
[Code]...
When i want to update a label that is on my main form (from the check_accounts sub). I know that isn't the right way, but i have no idea what the right way is. All the documentation i can find is very (excuse me for this) nerdy and really doesn't offer much insight on how to incorporate it into a project.
I want to be able to have a numericupdown box that can let the user change the amount of threads they want to use. I assume more threads allow the http requests to be done faster and at the same time?Also if i wanted to pause the HTTP requests, would the best method to use be pausing the thread?
I am working on an application that is taking pretty long to execute. I started playing with mutli-threading and it seems to have greatly sped up my app. Problem is that threads are still executing and the rest of the code executes before the threads finish. Here is my
So I am currently attempting to wrap my head around create multi-threaded programs and I am currently running into an issue when using a Shared variable across multiple threads.The program is structured as follows: Public Shared IsActive as Boolean
Main Thread = GUISets the Value of IsActive through a Button ControlTwo Worker ThreadsBoth threads are while loops that read the IsActive Boolean Ex:While IsActive = True Do Work End WhileHowever when I change the value of IsActive from the Main Thread it causes the worker threads to stop (ThreadState = 16).
I have been reading that I have to synchronize/lock shared resources and have tried SyncLock and Monitor methods without success (it is entirely possible I am not using the above correctly, so If someone could provide proper examples for the above situation using the mentioned methods please share them).
to some server via an UdpClient. However, I need to make sure that all commands send are separated by a 1 second delay. If there is no delay, two commands send within this 1 second timespan will not be received both; only the first or the second command will get through.he commands are sent in a background thread at the moment, because it might take some time before the command is sent. I keep looping until the command has been sent, like this:
vb.net Public Sub Send(command As String) Dim bytes = Me.GetCommandBytes(command)
I am getting error when I am putting my sendmail function into other thread. But without threading the message was sent successfully. I am getting error in this part when sending using thread. mail.Body = EmailBody.DocumentText It say: Specified cast is not valid. Here is my code for sending email EmailBody is a webbrowser in Desing MOde ON
I'm having some issues with parsing a lot of information into controls using winforms. I've tried adding threads/backgroundworkers, but they don't seem to work properly. To avoid the cross-thread exception, I had to add an invocation checker:If Me.InvokeRequired Then Me.Invoke(New MethodInvoker(AddressOf ParseSub()))This just freezes the form as it would without threading, but without the invoke checker I get cross thread exceptions because information from one thread is trying to be sent to another.
I started a threading project and want to manage my code so that it waits for all the threads to be finished before displaying to the user on the main UI thread that it has completed the task and waiting for the user... I've created a List to manage the threads and a global Boolean, "blnStop"...
I am working on an app and I am a bit confused w/ threading. I understand the point of threading but I am not getting when to use a background worker thread vs. a standard thread vs. a thread pool. Can someone shed some light on when to use which? Right now, I am trying code an app that does stuff initially in a sequential order and then eventually must thread (otherwise it takes forever). The problem I am having w/ the sequential stuff (and threading later) is that I need a button to be able to stop execution of code. [Code]
I did the background worker on this first sequential operation because when I tried w/ out it, the text box didn't update at all until the web page contents were retrieved. Basically, the text box change of "Starting." doesn't show up until the web page is finished processing even though the assignment to the text box happens before that code.
I'm loading 3 comboboxes and a treeview with values, from a remote database when the app starts. As we all know the app freezes until it's done loading. I want to speed things up.
Dim _thread As Thread _thread = New Thread(AddressOf test_loading) _thread.Start()
[code]....
When I execute this code I get the following error:
mycomboboc.Items.Add(reader.Item("columnname").ToString)Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on.
Currently I'm using System.Threading.Thread.Sleep(5000) to let my app pause/sleep for some time. This works great but I can't open my app anymore when it's sleeping and it uses about 25% of my CPU. I guess there must be a better way to do this. I also tried using a timer but that didn't work out to well for me..
For x = 0 To 7 Step 1 For i = 0 To 7 Step 1 Dim rectangleShape1 As New Microsoft.VisualBasic.PowerPacks.RectangleShape() 'create a new object to assign to the array location board(x, i) = New Microsoft.VisualBasic.PowerPacks.RectangleShape() 'create the new object in the array
When you declare an object 'WithEvents' and then utilize the "Handles" clause at the end of your event methods, how does Visual Basic manage a reference change for the object? In other words, if the withevents var is set to ObjectA, then later I switch it to ObjectB (or nothing), does Visual Basic automatically both remove those handler methods from ObjectA, and attach them to ObjectB? Or do I still have a ObjectA's events being handled behind the scenes?
I ask this because if instead you use AddHandler for an object, and then switch your reference, unless you removed the handler before switching, your original object is still handled (at least I'm pretty sure that's how it works).
If a create a wrong email lets say "email" the exception is correctly cached and a message is showed however is i input a valid email the event is not raised, the object is being created but no message is shown and no error or exception is thrown i suspect it has something to do with using "myemail = new Email(email)" but i have seen examples of using new with withevents with no problem.
I'm trying to create multiple instances of a child form. This form has an event that feeds a string variable back to the parent so I'm declaring it with WithEvents which is declared outside of the Sub - meaning multiple clicks will not open multiple forms.
another method of doing this while keeping the event?:
Dim WithEvents FRestoreDB As New FormRestoreDB() Private Sub BtnOpenDB_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnOpenDB.Click
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click TabControl1.TabPages.Add(gel) gel.Text = ("Gel")
Private Sub Gel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles gel.Click MsgBox("test") So my problem is that if I click on the tabpage gel, nothing happens.
I'd like to create an array of objects with events. Where do I need to put the "WithEvents"? Should it be placed in the ReDim line or the next one?I'm trying to use a "global" event, like objects of people that recieve a time-event to get older.
What is the optimal approach to a WithEvents Collection - VB.NET?Have you any remarks on the code bellow (skipping the Nothing verifications)?The problem is when I obtain the LinkedListNode(Of Foo) in a For Each block I can set myNode.Value = something, and here is a handlers leak...
-Could I override the FooCollection's GetEnumerator in this case? -No. :( cause NotInheritable Class LinkedListNode(Of T) Class Foo
The vb.net "WithEvents" syntax is very useful, but if a WithEvents field which references a long-lived object is not nulled out, it will often constitute a memory leak.Is there any easy way for a Dispose routine to have vb.net automatically clear out all WithEvents fields and unsubscribe them?
I've figured out a nice way to wrap the creation of disposable fields so that they will be automatically Disposed when the containing object is disposed, without having to individually list such objects. Is there any way to take care of WithEvents fields without having to manually null them out in the Dispose routine?
EDIT:Since there was no response indicating a built-in way to do it without reflection, is there any built-in means of using reflection to determine whether a particular property is a VB automatic implementation of a WithEvents "field"? I know that a WithEvents "field" called "foo" is implemented as a property called "foo" and a field called "_foo", but that's such a common naming pattern that I wouldn't count on it. Is there some attribute that could be used to determine which properties need to be auto-nulled?
Public WithEvents Tree as Tree. I am not able to Serialize the Tree class, but if i remove the "WithEvents" keyword, it works fine. Why? What should I do if I have to declare it with "WithEvents"?
I have done an extensive search before posting this question, using many different search parameters without success at finding an answer.Using Visual Studio 2008 Express VB:My program requires a notification when a wav file has finished playing, a media player song list will not suit my needs.I have used System.Media.SoundPlayer, Microsoft.DirectX.DirectSound and My.Computer.Audio.Play to play a wav file. All work well at playing and stopping the requested wav. So far, I have not found a methode to capture an event when the wav has ended. DirectSound stops playing when the form has lost focus, so I dont think that I can use it. Audio.Play AudioPlayMode.WaitToComplete only holds up other operations and I dont want to create multiple threads.