Run A Periodic Task In The Background In VB?
Mar 11, 2009What's the easiest way to run a periodic task in the background in VB?
For example: Update a label every second with the current time, while still allowing the form to be available.
What's the easiest way to run a periodic task in the background in VB?
For example: Update a label every second with the current time, while still allowing the form to be available.
I would like to get my program to run in the background. The EXE file I have created, I want it to run in the background and yet do not want to show the user that the program is running. Like I don't want to have the minimized screen on the task bar. Can I do it in my VB.net program.
View 10 RepliesCan i slow a task in the Background Worker down?
View 2 Repliesi have a win form, where i have a block of code which keeps checking for entry in database, every say 2mins, now i want to avoid using timer control, for performance reason, can the same be achieved using background worker.
View 1 RepliesI have been pulling my hair out trying to get this to work. If I step through the code in debugger it all works great. My problem is if I just run it, only the last task responds. I'm guessing I am overwriting the background working or something. I am sure I am doing a few things wrong but my code is now messy as I tried many way while searching. I know of the threadpool and .Net 4.0 tasks but having a hard time getting to do what I need.
Basicly I am writing a program (trying more likely) that takes a list of computers and pings then, then checks their uptime and reports back.This works fine in the UI thread (Obviously that locks up my screen). I can have the background worker just do this, but then it does each computer 1 by one, and while the screen is responsive it still takes a long time.
So my answer was to have a for loop for each server launching a new background worker thread. My solution does not work.I have seen other threads that I could do it, but I need to use with events to call code to update to UI when each is done.
What is the most simple way to do this?
Here is my code. Most is just copy paste + modify till I get it working right.
So In the main class I have the testworker.
(I tried using Testworker() but it said I could not do that WithEvents)
When I click the button the list loads.
Private WithEvents TestWorker As System.ComponentModel.BackgroundWorker
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
[Code]...
This is what I want, I have 12 progress bars and I want to run a background task to ping IPs and if it can ping them it starts a timer is this imposable to do?
View 4 RepliesI have a lengthy XML file that I want to search based on text that a user types in. Because it's lengthy, I want to wait for the user to stop typing for 250ms or so before I actually start searching in the background. I tried to kick off my Task, having it sleep for 250ms, then check if my CancelTokenSource had canceled because another character was typed. I'm not seeing a cancellation, though, so I end up seeing my results flash several times as the queued up search tasks complete, one after the other, after I finish typing.
View 2 Replieslook at the comments at the beginning of each class. Note, the period is rather small (100ms), and the process being triggered could occasionally take more than 100ms (in which case, the next thread trigger should be delayed ... two threads shoud never overlap). Also, the class will never be instantiated more than once.
[Code]....
is it guaranted that a task A started before TaskB will be completed before task B assuming the task do the same level of operatons?or in other words is there a chance that a task B will finish before tast A in the assumption that the task calls the same procedure?
View 4 RepliesThe drive is connected via USB and the problem I'm having is that, periodically, while my code is executing, the usb drive seems to disconnect and reconnect. (Nothing to do with the program, but the drive itself).I want to find a way to prevent these temporary drive reconnects from interrupting my code. IE, i want to insure that whatever read or write that is requested is actually executed even in the case of a temporary drive interruption.
View 1 RepliesBackground of form: black
background of char, bombs and shrooms: transparent
picbox behind char, bombs and shrooms is regular (marioland)
How can i fix it so the transparent parts dont see form as background but marioland as background?
I am using query from a SQLite database as the AutocompleteCustomSource for a ComboBox. Also, I want to load data in separate thread. My LoadData method works fine when called directly, but it fails when it is called from the BackgroundWorker thread. When it is called from the background thread, it throws a Specified cast is not valid exception on the csearch.AutoCompleteCustomSource.Add(hh("Taj")) line. Below is my code:
Sub LoadData()
Dim connetionString As String
Dim cnn As SQLiteConnection
[Code].....
what I am trying to accomplish worked with the code in the last thread I posted a while back. I still am using this code, however, I changed the window size to work better and gave it a nicer background for the title screen of my project. Now what I am working on at the moment is making a settings form that has 2 labels. One for "Default" Layout and one for "Plain" layout. When default is at start, the default label is disabled,and when plain layout is clicked, the button is disabled and default button is enabled.Basically, this is a toggle switch for default or plain where if one is enabled, the option for it is disabled and the other is enabled.My problem is that when I switch from Plain back to default, the background Image will not switch back from the plain background color of "control"Here is my code:
Public Class Settings
Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
MiDNiGHT.BackgroundImage = Nothing[code].......
I am having fun working with System.Threading.Tasks. Many of the code samples I see, however, look something like so:
Dim lcTask = Task.Factory.StartNew(Sub() DoSomeWork())
Dim lcTaskLong = Task.Factory.StartNew(Sub() DoSomeWork(), TaskCreationOptions.LongRunning)
Task.WaitAll(lcTask, lcTaskLong)
That's the extent of the sample.Tasks implement IDisposable, so obviously I'm supposed to dispose of them, but what if I just want to "Fire and Forget"?If I don't dispose, will I leak threads/handles/memory/karma?Am I using tasks "wrong"? (Should just use a delegate and leave tasks alone?)
Can I dispose in a "ContinueWith()"? (That seems like playing Russian Roulette.)[URL]..
My application displays a Splash Screen. In the Main form load event , we show another form in which user has to be select something. On the basis of that selection , the main form is loaded.
The scenario in which the main form is not shown in the task bar is :
1. Application runs , Splash screen is displayed.
2. a new window is shown to user to select something. this window comes over the splash screen.
3. Clicks ok on that window.The window is closed . Only splash screen is showing.
4.Now click on the space outside the Splash screen , the splash screen goes in backgound.
5. The main form is loaded. It comes for a moment in task bar but does not stay there. when i do alt+tab , it is there .
I have a MDI WinForms application that can perform several tasks. Each task is running as a backgroundWorker.What is the good approach to control the running threads:check whether the specific thread is running stop specific thread ?For example it shouldn't be possible to run the same task simultaneously.May be I need a separate class where I can store isTaskRunning variable?
View 1 RepliesHow can you do this? I want to have my program run every once in a while but I don't want to make it a service.
View 5 RepliesI was wondering how to set a task in my program, For example if the user selects to take a screenshot on a chosen date and time the program would take that screenshot at the specified date and time. I have a DateTimePicker for my users to select a specific date and time to run the task. Since the date and time includes the date i don't think i can use a timer. And FX Cop said that timer intervals shouldn't be longer then a minute.
View 4 RepliesI have a program and for now I am using timer for schedule a task but does not work as I want. I want for example run a task with a MonthCalendar.
View 3 RepliesI am writing a small app in VB and I would like to know how I would set it up so that when a user pressed a button, a sechduled task is ran. Keep in mind that this task is already created, I just need it to run.
View 2 RepliesI came across this code which should be able to compare my PC time with the time stored in theTime; however, I can't get it to work.
dim theTime as datetime
theTime = CDate(txtTime.Text)
if theTime.hour = now.hour and theTime.minute = now.minute then
[code]....
i'm building a custom control to draw graphics. In my control i have a picturebox and one propertygrid, what i need it's to hide all the public property's of the picture box (browsable(false)), but i don't see how to do it...
Other question, it's possible to add one task menu to my control? Kind of the the task menu of the datagridview where we can set the datasource...
TaskScheduler on Windows xp, does anyone know a API used to select a certain task to Run? or do I have to go through that darn COM ITASK interface, I think that might have a method?
View 6 RepliesI have a vb application. I assigned an icon to the app. It shows up with the file and when i create a short cut. However when it is running the default box icon appears in the task bar.
My class Inherits System.Windows.Forms.Form
What do I need to do to make the icon appear in the task bar?
I have to sync information between a users table in SQL and a user group in active directory. For example, if a user is entered into SQL table A then they need to be entered into group A and if a user is removed from SQL table A, then remove them from group A.The application is written in ASP.NET (VB)
I see two solutions:
1) A scheduled task that runs every night syncing the two (written in VB.NET).
2) Use inpersonation so that Active Directory can be updated by the ASP.NET application. The Web.Config file will have to be encrypted in this solution.
I have read articles online that say it is bad practice to update AD in ASP.NET. This would suggest that option 1 is the better solution. Which is the better solution?
I am developing a web application in asp.net vb. My current situation is,I have a main site say [URL] and another site for generating reports depending on certain user ids say [URL].If I click a button on [URL] I have to switch on the generate report page on [URL] and return to[URL]. [URL] should generate report and set a flag in database of [URL].Currently I am redirecting to the page in xyz.com and add the long running task to queue as follows and redirect back to [URL].
If ThreadPool.QueueUserWorkItem(New WaitCallback(AddressOf LongTimeTask), New Object) Then
Response.Redirect(returnURL)
End If
But the problem is its not dependable. Means some times the queue is executing correctly but some times not. There are no errors in long time task. Just the queue is not executing.
Is it possible to create scheduled task with VB.NET. That is I'm trying to launch/trigger my application at specific time.
View 13 RepliesI am currently creating a task manager. But there is a problem : After killing the processes, it still remains in my list box (list of processes).I don't want to use a timer to clear the list and add the list of processes again because this will cause the list to blink.[code]
View 7 Replieswhat is the difference between a task and a backgroundworker? when it is better to use one and when the other?
View 1 RepliesIs there a way I can place my form above the task bar?
Something like this: But, people have different sized task bars..
Is there something like: my.computer.screen.taskbar ?
My current code is: Me.Top = My.Computer.Screen.Bounds.Height - 116
Me.Left = My.Computer.Screen.Bounds.Width - 365