VS 2010 - BackgroundWorker Class Logic Ends Abruptly
Oct 8, 2010
I am trying to create a tool which executes some oracle procedures and telnet commands. Besides this Job my tool also needs to update a counter in some table in oracle db at regular intervals(10 secs as per current settings). So I used backgroundworker class in VB.NET to implement this back ground job of updating the counter. My problem is I have put logs at every possible exit of the backgroundworker_dowork functions but still this logic stops working after some time --7-8 hours. I am not able to understand when/where/why/how is it stopping? I am saying logic has stopped because it stops incrementing the counter. And am saying it is exiting abruptly because in _RunWorkerCompleted, I have written a log and closed the application but nothing comes in the log and application is not exiting.
Private Sub backlogicthread_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles backlogicthread.DoWork
WriteLog("Background worker", "entered")
dbbackcontrol = New OracleConnection(odbcBill)
Dim dr As OracleDataReader
[Code] .....
View 8 Replies
ADVERTISEMENT
Jan 9, 2012
I have 2 classess. Role and User like this
Role
Public Class Role
Public Property RoleID As Integer
Public Property CreatedBy As User
[code]....
The situation is like when we create roles, we will save who created this role. So i have a CreatedBy Property of type User. Similarly when we create a User, we will mention what role the new user belongs to .So i have a property called "Role" of type "Role". This circular reference giving me StackOverflow exception as its recursive when i create an object of User class.How do i handle this ? should i restucture my entties ? how ?
View 1 Replies
Sep 12, 2010
Going from VB6 to VB10 I find VB10 has much easier ways of doing things, like getting command line arguments, getting all subfolders, etc, the hardest part is knowing what commands to use. Is there a better way to detect if a string ends with certain text? I'm doing it like this....
[Code]...
View 2 Replies
Feb 17, 2010
my form displays locations and owners for a same product, the forms have a data grid view that actually takes in the details of the location and owner of that particular product. a product can have multiple owners and locations once its manufactured over time, the forms actually display this all i need is some kind of business logic that can actually manage the historical events of the location and the owner that when a user actually goes in and adds a new entry, the end date of the previous owner gets reduced to one less than the start date of the new owner. this in formation is stored in business layers called the owner collection and the location collection, i am not able to actually inherit or call the location or the owner collection class in the classes.
View 1 Replies
Jan 11, 2010
I have a backgroundworker that needs to contact a webservice. But when I run the background worker it just hangs forever at the line where I call a method of the webservice. I suspect this is because the webservice is defined at class level.
View 17 Replies
Jan 10, 2010
I have a GUI class and a database class. I do something like:
Dim db as Database = getDatabaseObject(logTxtBox)
db.executeNonQuery("some update command here")
Within executeNonQuery I connect to the db, execute the command, disconnect and catch the exceptions. logTxtBox is the GUI txt box I want log messages written to. Currently it writes something like:
Connected to DB successfully
Executing "some update command here"
Excepetion: ........
Disconnecting from DB
I feel like this isn't the best structure for my logging. As soon I kick off executeNonQuery with a BackgroundWorker instead of with the main GUI thread I cannot access the GUI's logTxtBox from the BackgroundWorker's thread. Is there a better way to implement this kind of functionality?
View 2 Replies
Apr 13, 2011
I am trying to run a backgroundworker to load data from my DAL (which is available in another class). I want to keep the UI available and not have the "locked up" feel while the object is loading.When I create a simple backgroundworker and Sleep the UI stays responsive and my controls can be updated after the sleep. As soon as I replace the sleep with a call to instantiate the object from my DAL, the UI locks up. Is there someway I can instantiate this object using the background worked and keep the UI responsive?
When the situation object is instantiated it could take several seconds for it to load completely, during this time is when the UI is locked up... It does eventually load just fine.
Private WithEvents backWork As New BackgroundWorker()
Dim sit As Situation
Private Sub btnLoad_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnLoad.Click
[code]....
View 1 Replies
Sep 14, 2009
I have designed a class for posting data to server, which is a time consuming task so that i have used background worker in my application. instead of repeatedly using backgroundworker in my application, i decided to add it to my class and generate two events PostWorkerReportProgress, PostWorkerComplted for my application
View 1 Replies
May 31, 2012
The goal is to check for invalid data (no data/negative numbers/letters where numbers should be), it does produce a message if the data entered is invalid, but I can't figure out why it STILL displays the results. Results should only be displayed if all data is valid.
View 6 Replies
Jul 15, 2011
I've done many attempts but still didn't succeed in making a logic for pascal's triangle, I want you guys to get me start this task and I'll code it myself. url....
View 5 Replies
Mar 29, 2011
I have setup an application to parse about 3000 files a day where each contains around 4000-5000 posts in xml format with like 100 fields. It involves a lot of cleanup and parsing but on average it takes around 6 seconds per post. Now I tried threading but because of the way I have everything set up with variables being overwritten etc...I have divided the files into different folders and just created copies of the program to run and access the assigned folder. It is running on a windows 2008 server with 16 G of memory and I am told I need to reprogram to speed up the process and also not use so much memory.
[Code]...
View 3 Replies
Nov 16, 2011
I have a BackgroundWorker in a vb.net program that is doing a lengthy data import routine. I want to modify its RunWorkerAsync method so that it fires a custom event on completion of the method. (So that a method in an automated process can respond to the event and resume its work). In a sense I want to 'extend' the RunWorkerAsync method to add an extra line of code--but I can't 'see' the code in the method (to just add the line raising the event) because BackgroundWorker is an MSDN class from Microsoft.The only solution that I can think of is to 'wrap' the background worker class in a wrapper that calls the .RunWorkerAsync method and then raises the event.
Public sub wrapperMethod()
myBackgroundWorker.RunWorkerAsync()
raise customEvent
end sub
Is there a design pattern that I might use? An easy way to address this with the .net language?
PS: Unfortunately, I'm automating some clanking legacy software and backgroundworker is used in many locations, so wrapping the backgroundworker will be a bit of work and may open bugs.
View 1 Replies
May 25, 2010
I'm slowly learning about loops. I have a couple of questions
1) When a condition is being tested.. what does that mean? I don't understand the "condition" word.
2) What is the difference between a loop that never ends and a loop that ends?
I have the code for the loop that ends and the loop that never ends. I can see the difference in the code, but I don't understand what is making it different. Here is the code below.
[code]...
View 1 Replies
Sep 3, 2010
The application uses ADO.NET to invoke sprocs for nearly every database operation. Some of these sprocs also contain a fair amount of domain logic. The data access logic for each domain entity resides in the domain class itself. ie, there is no decoupling between domain logic and data access logic. I'm looking to accomplish the following:
[Code]...
View 2 Replies
Apr 25, 2011
link where Programmers like me who are new and not very proficient in Vb.Net and ASp.NET..
View 10 Replies
Sep 10, 2010
I am working on a snake game for my portfolio and was wondering where the best place to put the logic for drawing the snake. Should the code reside within the snake object or within the form? Either would work, but I am wondering from a business objects/coding standard perspective where such code belongs.
View 2 Replies
Dec 14, 2009
in my button click event i ececure
If BackgroundWorker4.IsBusy Then
BackgroundWorker1.CancelAsync()
End If[code]....
after proceess completed if press the button again.i got the following error msg
This BackgroundWorker is currently busy and cannot run multiple tasks concurrently.
View 6 Replies
Jan 7, 2011
Here's my code :
VB
'Clearing the selected items of the listview
ListView1.SelectedItems.Clear()
'Random selection of farms from the listview
Dim random As New Random()
Dim rand As Integer = random.[Next](0, ListView1.Items.Count)
[Code] .....
I'm running it under a BGW and it works fine but is there anyone who can comment on it and make my code a bit better. I've a background worker and I am running it again and again on the RunWorkerCompleted like this
VB
Private Sub BGW_RunWorkerCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles BGW.RunWorkerComplete
BGW.RunWorkerAsync()
End Sub
Is it bad coding or is there any alternative to run it?
View 6 Replies
Sep 5, 2010
I have some issues with background worker progress reporting functionality. I'm implementing a progress indicator and even if I marked the backgroundworker as report progress (true), it won't report progress until it finish the job.
The code is like this:
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
action_1()
[code]....
The result is as expected (label1 with 100 value) but only when worker finished all the steps. If I'm triggering a messagebox in ProgressChange I see two message windows at the end of DoWork handle.
View 2 Replies
Feb 16, 2010
I'd like to have a backgroundworker process data that will eventually populate a gridview in my windows form. I need to use a backgroundworker because the process takes a little while, normally causing the program to slow/freeze until it's opening and streaming connections.. So, I'm using a background worker to perform these methods.How can I take the data from the background worker (on a separate thread than the UI) and use it to populate controls in the UI?
View 4 Replies
Sep 24, 2009
I have the download progress bar working in my program but I can't find any working code to determine the amount uploaded. here is my upload code
[code]...
View 6 Replies
Feb 16, 2010
I cannot figure this one out.. I have a background worker that will perform a task streaming data from some webpages. this data is then passed back and displayed in a gridview. It has been working fine.
I've recently implemented a listbox, which its values will be passed into the function that the background worker will perform as parameters, originally i had taken a single value from a textbox.
Now, I thought maybe it had something to do with the listbox, so I used a static value, just a simple String, as the parameter, and again, I get the TargetInvocationException was unhandled.. There's no difference in how I perform the task I'm trying to have the backgroundworker complete, the only difference is where it exists in my if condition statement:
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles ScrapeSites.DoWork
Dim results As ArrayList
Dim worker As System.ComponentModel.BackgroundWorker = DirectCast(sender, System.ComponentModel.BackgroundWorker)
[Code]...
View 3 Replies
Apr 27, 2010
i have a standard login form that allows the user to enter username and password and click OK or cancel. I have a progress bar called pbLaunch with the visible property set to false and the animation set to marquee. when the user clicks OK i would like to run a separate thread called bgwProgress that makes the progress bar visible and fires up the marquee just to show that something is happening while form1 loads up.....so far i'm stuckn the ok click event i have the following:
Try
Dim bgwProgress As New System.ComponentModel.BackgroundWorker
bgwProgress.WorkerSupportsCancellation = True
[code].....
View 38 Replies
Mar 3, 2011
I just want to to change a label name from the backgroundworker, the code is plain simple:
label1.text = WebBrowser1.DocumentTitle and the error returned would be "Specified cast is not valid".
Now running the code from a button would do the job, but from the bgworker not, and I can't seem to get around it.
View 4 Replies
Jul 1, 2010
A BackgroundWorker thread can pass data to the primary thread. It does it via the RunWorkerCompleted and ProgressChanged events, which I believe run in the primary thread. I would like to encapsulate the BackgroundWorker control in a class so that I can instantiate it more than once. But I don't know how the BGW can then communicate with the primary thread. If the BGW control is within a class, it does not have access to the properties outside the class. In that case, how can the BGW pass data to the thread that instantiated it?
[Code]....
View 3 Replies
Oct 14, 2009
I have a class that downloads a specific file from the net.This class uses a BackgroundWorker. I tried to implement kleinma's Download Files From Web With Progressbar [URL]../showthread.php?t=396260), but I'm having difficulties making it work. I'm including a test project, so if someone is willing to take a look at it, it would be great .
The part I'm having trouble with is updating the progressbar and progress label. The errormessage I receive is in Norwegian, but it has something to do with threads. I suppose I should use Invoke or something, but I don't know where to start..
View 14 Replies
Apr 18, 2012
I'm struggling with a thing or two...and i've read some stuff about the backgroundworker but im stuck Basically what i have is a : PUBLIC FUNCTION TEST (path as string) : which at the end of work , adds an item to the form1.listbox. That works quite nice but freezes the app. I've tried using the backgroundworker, the function in the background worker seems to work nicely, the bad thing is that i dont get any results in the form1.listbox.
View 14 Replies
Jan 19, 2012
I've wrote this code to accomplish what the image below looks like. This works fine for anything that is around 40x40 but if I try to do 100x100 it takes forever and sometimes errors out with a window handle error. Once it gets around the 40th column the labels start adding slower and slower. Is there anything I can do to make this more efficient? I added the backgroundworker routine in there to see if it would speed things up at all but it doesn't.
vb.net
Private Sub CreateGrid(ByVal rows As Integer, ByVal ranges As Integer)
If Me.InvokeRequired Then
[code]....
View 5 Replies
Jul 5, 2011
I have a backgroundworker that is downloading data from different webpages and process them to a datagridview.I get the Cross-thread operation not valid error on the first For loop.
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
dim i as integer
tot = (numPostnrTo.Value - numPostnrFrom.Value) / 10
[code]....
View 12 Replies
May 22, 2011
I want to execute a few external apps, where in between a RichTextBox gets updated.. Say when program1 has been startet the RichTextBox is updated.. And when program2 has been startet the RichTextBox is beeing updated again.So what i've done so far is this:
Public Class Form1
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
[code]....
But when doing the above i get the following error:
Quote:
Cross-thread operation not valid: Control 'RichTextBox1' accessed from a thread other than the thread it was created on.
View 3 Replies