Create A Daemon Thread That Sleeps For 30 Seconds?
Jul 31, 2009I want to create a daemon thread that sleeps for 30 seconds and looks in a directory for a database then opens the database.
View 4 RepliesI want to create a daemon thread that sleeps for 30 seconds and looks in a directory for a database then opens the database.
View 4 RepliesHere's the routine:
[Code]...
The problem - The btnPause doesn't pop up until AFTER the thread sleeps, but the other two buttons works correctly. What the heck is going on? Here, I'm using the Sleep to simulate doing external events yet to be programmed.
I have been making a downloader in vb.net everything is working fine Appart from the downloading, it takes around 10 seconds for the download to start Is this normal or am I doing something wrong?The download is being done in a thread and before when I have tried to download outside of a thread the program dosnt respond for those 10 seconds
[Code]...
I 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]....
i am trying to use the sleep command in vb 2008 multiple times to constantly change back color but am told, Unable to load DLL 'Kernel 32': The specified module could not be found. (Exception from HRESULT: 0x8007007E). i tried it with another program and one sleep(1000) and it worked so is there a way to use this multiple times or any other command.ian hendry
View 7 RepliesI have three sets of labels, lbl_seconds, lbl_minutes and lbl_hours. These labels have the default value of 00:00 and I want the timer to change that for each label. I have googled this but I cannot seem to find any good info on it. Do I need three separate timers? I have also noticed that the timers have their own tick event handler. I guess it's in this that I need to change the value of the label. But I cannot figure out how to do just that.
View 2 RepliesI need to create an on-screen shape (circle) that has a fill color, which will blink every X seconds (go from fill color, to white, back to fill color). This is trivial to do...BUT... i want to do it in my own class, so that I can instantiate it numerous times passing it unique coordinates for each instantiation.
How do I do it? Can a class have its own "timer control" in it independent from the form? How would I draw a shape from a class?
I want to convert seconds such as 254565443 seconds to hours, minutes, and seconds and thought if I could remove the decimal and the numbers behind it and not change the number in front of the decimal then it would work.
dim seconds = 254565443
dim Hour
dim minute
[Code]....
This is my function to goto a specific time in a movie or music, ... check it out..
'GOTO TIME IN MOVIE, or SONG.
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
[Code]....
In one application, I need use 4 simultaneous threads.When the threads finished, I need to update the text of a TextBox.So, I create 4 Textbox, and I wanna the threads change the text to FINISHED.Each thread change one distinct TB.I use this "example"
Dim Terminados As Integer = 0
Private Sub frmEnviarMensagem_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True
Timer1.Start()
[code]....
The problem is, I have an error in the red lines.The error is: INVALIDOPERATIONEXCEPTION "Cross-Thread operation not valid: Control tbPlaca1 Accessed from a thread other than the thread it was created on."I don't use cross threading. Each TB only was accessed for the correspondent thread, and for the "main program".
This is the error message I am getting:
"Cross-thread operation not valid: Control 'Panel1' accessed from a thread other than the thread it was created on." The reason I am getting this error is because I am opening up a new form and then calling these three things:
Panel1.Show()
Label1.Show()
Label2.Show()
why I get this error message because it doesn't occur normally if I open Form2 after closing Form1, it only occurs when I open Form2 after closing Form4.
I have done a program using vb2005 to display reading from my microcontroller bs2 board but have encountered some problems. My code are as follows.
Dim Stop_Rx As Boolean
Private Sub btnRead_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRead.Click
SerialPort1.Open()
[code]....
I've encounter an error which is, (Cross-thread operation not valid: Control 'txt1' accessed from a thread other than the thread it was created on.)
When my client try to connect to server I'm getting this error : Cross-thread operation not valid: Control 'l_users' accessed from a thread other than the thread it was created on.
Private Sub _socketManager_onConnectionAccept(ByVal SocketID As String) Handles _socketManager.onConnectionAccept
l_Users.Items.Add(SocketID)
End Sub
Would 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]...
My understanding is that thread.join will suspend the execution of code on the calling thread until the spawned thread finishes or is aborted...
With that in mind, I tried this:
For i = 1 to 50
threads = New Thread(AddressOf test)
threads.IsBackground = True
threads.SetApartmentState(ApartmentState.STA)
[CODE]...
However, the rest of the code runs when the loop finishes, not waiting for all the spawned threads to finish. Since the rest of the code needs the threads to finish (otherwise the rest will error).
I have written an application that loads a form - frmCad as well as AutoCad. It does this via a class which detects when AutoCad quits.
Friend Class CadApp Private WithEvents AppObject As AcadApplication... Private Sub AppObject_BeginQuit(ByRef Cancel As Boolean) Handles AppObject.BeginQuit RaiseEvent Quit() End SubEnd Class
My main class loads frmCad as well as CadApp.
Public Class Cad Private WithEvents frmCad As CadForm Private WithEvents app As CadApp... Public Sub ShowForm() If frmCad Is Nothing Then frmCad = New CadForm frmCad.Visible = True End Sub... Private Sub app_Quit() Handles app.Quit frmCad.Dispose() frmCad = Nothing .... End Sub
When I debug the program, it stops at frmCad.Dispose()The program continues to execute, but all the code after it fails to work.Looking more carefully I get an error message which contains:-Cross-thread operation not valid: Control 'Autocad' accessed from a thread other than the thread it was created on.
My error:Cross-thread operation not valid: Control 'label2' accessed from a thread other than the thread it was created on. I want to be able to give my Public RunBot() sub access to edit Labels, buttons, etc without an error.
[Code]...
I'm getting the 'System.InvalidOperationException' error on acccessing a thread from other than where it was created. My code is:
'Required by the Windows Form Designer
Public components As System.ComponentModel.IContainer ' changed from private
[code]....
My problem is Cross-thread operation not valid: Control 'statusHO' accessed from a thread other than the thread it was created on.
System.InvalidOperationException was unhandled
Message="Cross-thread operation not valid: Control 'statusHO' accessed from a thread other than the thread it was created on."
Source="System.Windows.Forms"
StackTrace:
[Code]...
i used it and it works fine then. but as it is mentioned its not a good practice to use it. So what should i do? is it ok if i use this as i am not able to use correct practice. Mine application is not for enterprise purpose. its just my class project, and it works fine even if i put application working in background. System works ok. I dont know how to correct this error.As i dont have that much knowlege of threads.
So please guide me how to fix this in correct way otherwise i am force to go for bad programming practice
Please refer to Windows Mobile Developer Center > Smart Device Development Forums > Windows Mobile Development > Appendtext not working for all my code details
Cross-thread operation not valid: Control 'lv1' accessed from a thread other than the thread it was created on.
Dim lvi As ListViewItem
For Each lvi In lv1.Items
[code]....
Quick question - if I have a timer set to 5000 (5 seconds) and the code in the timer takes longer than 5 seconds to run because of sql stuff, will the timer wait until the code is done till it fires again?
View 3 RepliesThe usual VB way to handle a computationally heavy task is to put it in a background worker thread, while the main thread keeps handling the UI.Say for whatever reason I needed to do this the other way around: the main thread doing the grunt work and the background one updating the UI.Here's what I have so far. The only problem is, while the UI window (Form1) does get redrawn, you can't interact with it, not even move or resize it (the mouse cursor turns to hourglass and won't click).
Public Class ProgressDisplay
Private trd As Thread
Public Sub New()
trd = New Thread(AddressOf threadtask)
[code]....
The client will call it like this (actually in unmanaged c++ over COM but you get the picture):
Dim prog = new ProgressDisplay()
DoLotsOfWork(addressof prog.update) ' DoLotsOfWork method takes a callback argument to keep client informed of progress
I am trying to create a new thread using an anonymous function but I keep getting errors. Here is my code:
New Thread(Function()
// Do something here
End Function).Start
Here are the errors I get:
New - Syntax Error
End Function - 'End Function' must be preceded by a matching 'Function'.
I'm trying to change/execute the example [URL]...onContext.aspx I've posted my project below. I'm getting a cross-threading error and I thought the point of all of this was to avoid that. (yes I realize I could just delegate... I'm trying to do something more complicated but am using this as a test bed)
[Code]...
I would like my application to do something (in one form) and while form is doing that i would like to show another form to the user. Code is:
Private Sub blaa()
Dim a As New Working() 'working is another form
a.Show()
'Do some stuff
a.Close()
End Sub
But when i make new form i find it is on the same (main thread) and therefore new form also frozes. How to make new form on separate thread?
I read several posts but I didn't still find solution on my problem I created 2 forms: first is main where I do operations on excel file with 20000 rows and in second form I created progressbar. the name of main form is form1.vb and the name of second one is wait.vb In main form I wrote:
[Code]...
Ok i have a Form with the following
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txtNotepad.Text = LoadFile("notes.txt")
[code].....
I have searched the forum and found several forums related to the backgroundworker thread but have been unsuccessful in finding my answer.My objective is to display an animated gif or progress bar while the program is executing a particular method which can take upwards of several minutes to complete. I cannot get the second thread to run the progress bar while the main progrem is executing the time consuming method. I have created a demo based on another thread and can't seem to get it to create two threads. I was attempting to get the backgroundworker to execute the progress bar while my main code runs on UI thread.
[Code]...
I am currently creating an application which monitors any errors that occur in the other applications I have developed.
One thing that I want to try and do is add a sort of discussion thread into the form, so this allows for each member of IT to add comments/notes about the error that occurred.
Normally I would just use a DataGridView or a ListView, but I would like to have the capability for the comments/notes to be multi-lined so that the user can see what has been written without having to scroll sideways.
Currently I'm creating a task that runs a hardware i/o loop for the duration of my program.i.e. it's a task that's created at the program's start and runs a loop that is only broken at the programs termination. Each loop cycle communicates via ethernet to hardware.depending on time outs each cycle takes 30-300 msec)I've noticed that if the loop runs with out any break that the program really slows down... to counter act that I placed a thread.sleep(x) in the loop
View 6 Replies