VS 2008 BackgroundWorker1 Or System.Threading.Thread
Apr 25, 2012What is the difference in using: BackgroundWorker1 or System.Threading.Thread
View 3 RepliesWhat is the difference in using: BackgroundWorker1 or System.Threading.Thread
View 3 RepliesI cant get System.Threading.Thread.Sleep to work..[code]
View 2 RepliesI have 5 Picture Boxes, each picture box has an image but all 5 of them has a visibility of false. I have a button, when clicked will show 5 of the images. But showing the 5 images with a delay. So it's going to be
[Code]...
I have this little application that is using a System.Threading.Thread.Sleep, application runs great but Windows thinks the application is not responding even though it is running.
[Code]...
What is the difference between creating a thead using BackgroundWorker and creating a thread using System.Threading.Thread?
View 2 RepliesI want to have My.Settings.Delay in seconds not milliseconds adding the 000 for the user. I tried My.Settings.Delay + 0 + 0 + 0. but can't sort how to do this.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim var As Integer
Dim startVal As Integer
[code]....
im trying to terminate a threading.thread using thread.abort the thread runs a download connection so is usually in the middle of socket.recieve or socket.send or socket.connect when aborting i just want to terminate the thread no matter what thread.abort raises an MDA excpetion. so i ticked it off in the debug exceptions menu. now it doesnt raise an exception, but the thread simply wont terminate. my program wont close unless i press top in the debugger.i cant pause downloads because i cant terminate the thread this code wasn't working?
Dim vT As Threading.Thread
For Each vT In clsDownloader.DownloadThreads
If Not vT Is Nothing Then
vT.Abort()
[code].....
as for the exception concerning threads being aborted from other threads being dangerous, how is it possible to send a message from a main thread to another thread to abort itself? as far as i know the only way to a abort one thread from another is to just kill it (because i dont know of ways for a thread to communicate with another).
I have a string in which for sure there is a date in the following format: YYYYMMDD. So, to identify 14 October 2009 I'll find 20091014.Having this string, how can I format into System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern?
View 4 RepliesWould anyone be able to help me here please. I'm fairly new to VB.net and threading so im just trying to figure out what is happening.When I debug this I am getting the error thread operation not valid: Control 'ProgressBar1' accessed from a thread other than the thread it was created on.
I'm a little lost as to why the error is occuring or how to fix it. I've had to put the progress bar in a separate thread otherwise the GUI crashes
[Code]...
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..
View 5 RepliesI've been trying to use "System.Threading.Thread.Sleep(15)" as the delay code but if freeze the form. I used this "Location.Refresh()" where location is the name of the form, but it didn't give me what I need. This code is going to work on a ProgressBar while typing and the value of the progress bar change while typing. The progress bar jumps to the new value and I want it to move. So I thought about puting it in a "For ... Loop" but the whole form freezes.
[Code]...
i got inside
WebBrowser1_DocumentCompleted sub
the code below
WebBrowser1.Document.GetElementById("form").InvokeMember("click")
Call ProcessNextLine()
when it clicks this button it should load another page(Like log in)
Call ProcessNextLine()
takes next line from txt file (It's url) + navigate
but I want it to wait let the page load before calling "Call ProcessNextLine()" I tried System.Threading.Thread.Sleep not working?
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.
The coding that I have a problem with might make people think that I am creating some malware. So the project I am doing is associated with iTunes. iTunes allows people to have one library. There is another way, but it is very confusing to some people, and very unreliable. So my project is that I will allow people to have multiple iTunes libraries on one computer. So the problem is this. In order to have an option to choose your library, I gotta make sure that iTunes is not running.
So this is the script:
Private Sub CheckAndCloseiTunes()
retry:
'Custom class that includes the function to safely close iTunes
Dim Processes As Process() = Process.GetProcessesByName("iTunes")
[CODE]...
So when I use the Threading.Thread.Sleep(2000) code, the form becomes unresponsive.
Im trying to do this
[Code]...
But it will just skip to the last status (Label3.Text = "Status: Welcome")
I'm just looking for other people's thoughts and opinions on the way I have done something.I have a console application which needs to connect to various computers and reset the local admin password on each one. I got it all working but then decided that as there are a lot of PCs, it would be a good idea to use the thread pool to do a few at the same time.The problem is, I need this program to be run without any human interaction - so I cant just use ThreadPool.QueueUserWorkItem and pass it all of the computers to connect to, because then the program would exit after it had called QueueUserWorkItem for each one because there is nothing left for it to do. I cant stick a Console.ReadLine in there because like I said, it needs to be run automatically without anyone typing anything.
View 1 RepliesTrying to get System.Threading.Timer to work!! I am converting a small form based application to run as a services, The app just runs an monitors a folder and then when it finds a file to does some work on it. Having changed the form.timer to threading.timmer - The timer stopps working after a while. Below is a simple test services - when you look in to the text file it stops after approx 130 entries
[Code]...
I'm adding multi-threading facilities for the first time. I have a function that is wrapped to be run in a separated thread. This function retrieves data (text) from a combobox and it works for sure without multi-threading.
When I call it as multi-threaded, I get the following error when I try to retrieve the data from the cmobobox: Cross-thread operation not valid: Control 'cmb1stBL' accessed from a thread other than the thread it was created on.
It looks like a restriction of thread-safety... I assume that the child thread cannot read from his parent, to make sure that he doesn't change his parent data. So how can I read the data from the combobox? Should I read the comoboxbox data before calling the child thread?
I am trying to pass some status from a IP call in a shared sub to a label on my form. This is the current code that i am using:
[Code]....
I looked around the site and the questions I found relating to this subject were for C# (the application that I am maintaining is written in VB.NET), so I apologize if I overlooked one. Here is where I am calling my thread:
[Code]...
I have a problem with releasing locks on a thread. [Code] If Me.IsStarted Then 'checks if my service is started and ready of service requests 'code here to enqueue my job and objRxResult with the service so it can populate it with the result before Pulsing back 'the service has its own thread that it dequeues jobs off of and processes them on it own time 'during this key enqueue phase we block attempts to stop the service, thus the _objIsStarted lock [Code].
View 4 RepliesHow can I make my apparently so that when I click a button, it executes a sub of my choice on a seperate thread? I need this to send an email and when I ran it normally it crashed my GUI.
View 1 RepliesI am using a background thread in my application. The problem is: this thread starts when a button is clicked and it works well. After finishing it's work i can see the result. But when i try to start again, it gives me an error. How to restart a thread?
[code]...
When i press ToolStripButton1 for the first time it works really well. But when i press it second time it shows me error that, the thread has already been started.How to resolve it? I think how to restart thread is my question.
In frmMain:
Private Sub DBReadAccountInfo(ByVal strAccountID As String)
Dim tmpaccountInfo As New PublicFunctions.clsAccountInfo
tmpAccountInfo.strAccountID = strAccountID
Dim ReadAccountInfo_Thread As New Thread(AddressOf tmpAccountInfo.DBLookupAccount)
ReadAccountInfo_Thread.IsBackground = True
[code]....
In "sub UpdateAccount", frmMain.InvokeRequired is always false. There's a MenuStrip control I'd like to update the .Text on.
I have created a class for Socket reads so I can create sockets on command. Due to performing a socket read, the program will freeze waiting for incoming data due to being on a single thread. So I created a separate thread for the reading of the sock and attempt to invoke an event to prevent multi-threading errors.
But I am getting an error when trying to Invoke: "Invoke or BeginInvoke cannot be called on a control until the window handle has been created."
How can I fix this or is there a better way to read a sock without freezing the thread?
Class for Sockets:
Option Explicit On
Option Strict On
Imports System.Text
[CODE]...
Calling form code example:
Private WithEvents Socks As clsSock
Private Sub Sock_Connected(ByVal state As String) Handles Socks.Connected
MsgBox("Connected - " & state)
[CODE]...
I have the following code. My program loads 20 pictures in one panel and each pictures has for the moment like 500 Kb, but in the future they shall have like 2~6 Mb.When I use this part of code, my program that uses only 6 Mb of memory, but jumpes at 202 Mb when pics are loaded. I need a method to resize or make them thumbnail or something to reduce the memory.I don't know for the moment how to use the System.Threading, but I want to know if it shall help my program, if not, then help me replace parts of my code.Private Sub PanelPictures(ByVal picsoriz As Integer) ' picoriz represents how many pictures should the panel have on each row (it's set at 5 pictures per line/row) [code]
View 4 RepliesI'm developing an adding for office powerpoint application.I'm trying to display a description of the object(Customized object) currently dropped on the powerpoint slide in design mode(Design mode of the powerpoint).When i click on my addin the related object description will be displayed on a tabbed window as the first tabpage.
There is a button on the tab page, and when i click on it i need the description to get copied to windows clipboard.I tried this using clipboardclass it throws the following exception, System.Threading.ThreadstateException {"Current thread must be set to single thread apartment (STA) mode before OLE calls can be made. Ensure that your Main function has STAThreadAttribute marked on it."}
Code for clipboard:
Clipboard.Clear()
Clipboard.SetText(lblObjectID.Text)
I searched the net for a solution and got couple of answers like, Put [STAThread] in the main function Thread.CurrentThread.SetApartmentState(ApartmentState.STA) Immediately before your call to SetDataObject.
But I'm not sure where to put the 1st one and the 2nd option didn't work.
I have used system.timers.timer to watch several folders and move files in my windows service. But the timer event stops now and then. I have read that it is better to use system.threading.timer in services.This is my system.timers.timer
Private Timer As New System.Timers.Timer
AddHandler Timer.Elapsed, New System.Timers.ElapsedEventHandler(AddressOf Me.Timer_Elapsed)
Timer.Interval = 4000
Timer.Start()
[code]....
How do this code look like in system.threading.timer?How do i start and stop the timer using threading? That is very important because i stop the timer when it comes to the elapsed event and when the code har run it starts the timer again!
I have finally figured out how to download a file with background worker and downloader. Now the form does not freeze.. I have only one problem left now... How do I get the progress bar to increment in tandem with the data flow? I have listed my full code below. Towards the bottom where the DoWork() sub resides, I am just a few lines short of this year long goal.
Imports System.IO
Imports System.Net
Imports System.Text
Public Class Form1
[CODE]...
I have the below code in my ASP.net page:
Response.StatusCode = 404
Response.Write(strResult)
Response.End()
The code above throws "An exception of type 'System.Threading.ThreadAbortException' occurred and was caught."