Multithreading - .NET DataGridView Load Data From A Background Worker And SQLDataReader?

Mar 28, 2012

I have a DataGridView that I'd like to load with data that I'm retrieving from a SQLDataReader running in a background worker as the data comes in (it's a query that takes a long time). My goal is for the user experience to be similar to searching for a file in Windows where the results appear in the list as they come in and you can still interact with the window.

I have it working with a background worker and data reader and I'm trying to add the row from the SQLDataReader.Read through using the BackgroundWorker.ReportProgress method. Everything technically works but the flicker is crazy and the form is unusable (probably not because the GUI thread is blocked but just because there's so much going on...) How do I make loading the datagridview "smooth"?

View 1 Replies


ADVERTISEMENT

Multithreading - Load Data In Background Mode Using Background Worker?

May 3, 2012

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].....

View 4 Replies

Multithreading - .NET 2008 Background Worker?

Apr 14, 2011

I have created a background worker using a tutorial. I understand some basic stuff like how to update a label or a progress bar from inside of it. The purpose of this background worker is setup a bunch of variables that are going to be used by several other background workers later. The variables i am setting up are 6 different lists and a multi-dimensional array. The code looks like this for the background worker at the moment.

Private Sub My_BgWorker_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles My_BgWorker.DoWork
For i As Integer = 0 To m_CountTo

[code]....

I would normally use the persons.add to add something to the list, but I'm having a really hard time wrapping my brain around an easy way inside of the backgroundworker to add new values to several different lists(which are going to vary in amount of data values). Is there an easy way to do this? I'm used to just having invokes at the top of a sub to do this but those don't seem to work inside of a dowork sub.

View 1 Replies

Multithreading - .Net Asynchronous Background Worker Inside A Loop?

Jul 8, 2010

Im using Vb.net visual studio 2008. i have got a process(system.diagnostics.process) to be run in background and it updates the Ui thread progressbar and a label and i have worked it using backgroundworker.runworkerAsync. Now the problem is i have to work the same process for a number of time with different inputs.

The code block is :

Private Sub fnStartEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.click
Dim inputFolder = Directory.GetFiles(textboxSourceFolder.text)
Dim currentNumberOfFile As Integer=1

[code]....

The problem in here is the fnStartEvent method once gets started, it calls BackgroundWorker1.runWorkerAsync process and that runs in a seperate thread and does not wait for the thread to complete and it moves to the next line of code i.e loops to the next item and it returns to same BackgroundWorker1.runWorkerAsync line and throws exception that it is already running.

Tried

1.
Private Sub fnStartEvent(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.click
Dim inputFolder = Directory.GetFiles(textboxSourceFolder.text)
Dim currentNumberOfFile As Integer=1

[code]....

But this does not updates the Ui thread used to denote progress.

2.Put the whole process inside the DoWork thread and loop for each file in there itself, but that to returns the cross thread error in progress bar updation.what is the standard procedure in executing a loop for the backgroundworker to wait for finishing as well as update the UI without blocking it.

View 1 Replies

Multithreading Efficiency (Reuse Background Worker Subs / Functions?)

Oct 3, 2011

I have an application that queries DHCP and pulls scope/subnet information. There are roughly 8k scopes on our network to query so reporting this data takes a little bit of time. I currently have this running on it's own thread and reporting to a progress bar so the applications doesn't seem inactive.

The DHCP api functions can report a total, a max read and a resume argument. This means that I can, in theory start 4 threads and have each thread read through 2k subnets, so it will only take 1/4 of the time to read all this data. Would I need to create four separate background worker handlers, do_works, runworkcomplete, report progress etc.?

View 3 Replies

Load Form And Use Background Worker

Jun 11, 2009

i tried add :

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Raise the DoWork event in a worker thread.

[Code]....

View 1 Replies

Datagridview With Progressbar And Background Worker?

Jul 13, 2011

I have 2 forms (let's call them form1 and form2). Form1 has a datagridview that is populated by a combobox, when the selectedindex changes the datagridview is re-populated. Form2 is a small blank form with just a progressbar on it (progressbar1). Right now if I make Form2 visible when selectedindex is changed the marquee on the progressbar doesn't really move and Form1 is essentially "locked up" until the records are done loading into the datagridview.

[Code]....

View 8 Replies

Delegates, Background Worker And DataGridView?

Jun 5, 2011

I have a form with a DataGridView control. When i load the form, i fill the control with several records. Now sometimes it can be 1 to 30, but sometimes it could be 10000+ records.Now, what i'm trying to do is to grid.AutoResizeColumns

As you can imagine, when i have 30 records it goes like the Flash, but the more records, the longer it takes; obviously..So, for now i have a ugly label saying "WAIT PLEASE" and waitcursor=true; Yes, horrible, i know...

So i tried to do the following:I created a form called frmWAIT, and have a timer in it that shows 4 pictures at 250ms intervals, to make some kind of animation.In my Primary form, i added a BackgroundWorker, and in the DoWork Event, i tried to grid.AutoResizeColumns and it won't do it.

[Code]...

View 5 Replies

Populate Datagridview Using Background Worker

Mar 29, 2009

I hope someone can guide me in the right direction. I'm using VB2008 and I have been writing some small apps just to get me started in programming (I'm pretty much a newbie) and all was going well until now. I recently was experimenting with an n-tier style application. My application is as follows:

1) SQL Server 2008 database

2) Data Access Layer

3) Business Logic Layer

4) WCF Service

5) Winforms Client

My Winforms client retrieves data from the database via a call to a WCF service. I want to make the UI more responsive and to prevent it from locking up when its pulling down data from the database and populating a datagridview. I have looked at the background worker component but I am unsure how to implement it properly. To currently populate the DGV I simply use the click event of a button, as follows.

[Code]....

View 2 Replies

VS 2010 Datagridview/Background Worker (ByVal)?

Jun 19, 2012

It's always been my understanding that ByVal means is that you are passing a copy of a variable to your Subroutine. You can make changes to the copy and the original will not be altered.So if that's true I have two questions- How is my DataGridView updating without me passing the arguments back to it- The backgroundworker works fine as long as I don't reorgnize the columns in the datagrid.

'I pass the rows of my datagridview to the background worker
bgwGetHostStatus.RunWorkerAsync(dgvMonitoredSites.Rows.Cast(Of DataGridViewRow).ToArray)
'It grabs a website name from the IP column and reports if it's down or not in the status column. Now if

[code].....

View 2 Replies

WPF Background Worker Not Recognizing Worker Object

Mar 11, 2009

I have the following code that adds a background worker into a VB.net WPF project:

Imports System
Imports System.ComponentModel
Imports System.ComponentModel.BackgroundWorker

[Code].....

And I get the following error for the DoWork worker event:

Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

It seems like it's missing something in the Event declaration, but can't find it.

View 3 Replies

Created Datagridview Control Used To Display The Data Using Sqldatareader?

Apr 15, 2010

I am having problem with datagridview. Actually I have created datagridview control used to display the data using sqldatareader. My problem is that How can I fill the data in textbox control when user selects the row in datagridview using coding. For e.g. my form is having a) Datagridview and displaying values of columns: Name, Address, City, State etc and textboxes: txt1, txt2, txt3, txt4. Now if the user selects any row from datagridview the selected value of Name is filled with txt1, address is with txt2, city with txt3, state with txt4. I am directly dealing with database with using DataAdapter.

View 1 Replies

Create A Datatable And Try To Load Sqldatareader

Apr 6, 2010

Scenario is this; I've a sqldatareader query that seems to be returning nothing when I try to convert the sqldatareader to a datatable using datatable.load.So I debug into it, I grab the verbose SQL query before it goes into the sqldatareader, just to make sure it's formatted correctly. I copy and paste this into SQL server to run it and see if it returns anything. It does, one row.I go back to visual studio and let the program continue, I create a datatable and try to load the sqldatareader but it just returns an empty reader. I'm baffled as to what's going on. [code] Ok I've done a loop to count the rows of the datareader before using the datatable.load method. In my test query I'm getting 4 rows (the correct amount) in the datareader, as soon as I use the datatable.load method it says the datatable is empty, what's going on?! So it seems a datareader is a one-way thing, iterate through it to get the row count and it's essentially empty as far as any other bit of code is concerned. Didn't realise it was forward only and wouldn't 'reset' once read through.

View 1 Replies

Using A Background Worker?

Jul 15, 2011

I'm writing an application in Visual Basic Express 2008, part of the function being to walk through a folder structure starting from a user specified folder. In my research, I found this thing called a background worker which seemed an appropriate tool to use given the potential size of a target folder structure. I successfully installed the two examples from the library here, and believe I understand the principles involved. Even so, having tried to build this feature into my application, it seems as though it is not working as expected, and, as predicted, debugging a multi-threaded application is a pain in the extremity.

I have this fragment under my "start" button click event -

HomeSource.Enabled = False
HomeCopy.Enabled = False
HomeReport.Enabled = False

[Code].....

View 16 Replies

What Is A Background Worker

Jul 18, 2010

im thinking just because an app has been sent ton system tray does not mean its a "back ground worker"

View 1 Replies

.net - Progress Bar With Background Worker

Jun 7, 2012

my backgroundworker as I just cant get it to work. Basically I have a backgroundworker which does a few tasks but I'm trying to implement a progress bar and a label. I'm going to set the maximum value of the progress bar to 10 and then have it updating as I move with each task, also I'm thinking of a label with the progress bar which will display the progress ie

[Code]...

View 2 Replies

Add Progress Bar With Background Worker

Oct 7, 2009

I'am trying to make app that will show every file in C:[code]Now how can i add progress bar with the background worker.

View 31 Replies

Background Worker RunWorkerCompleted?

Nov 20, 2008

I have a background worker that used to fire its RunworkerCompleted event when its DoWork routine finished querying a database and writing its output to a file. The bg worker was in a class called Query, which was called from another class called Trigger. A new Trigger Class was created for each monitored event. In this class, there was a structure which stored the config of each Trigger. When this event was triggered (set to TRUE) a new query class is created and it is passed the Trigger class. When the database query, file writing was done, the query class and all its rsources were diposed from the RunWorkerCompleted EventRecently I changed the application so that a new trigger class is not created for each monitored event. There is a single instance of the class but new config structure for each event. When a particular event is trigger, jsut the config structure is passed to a new query class and the sma ething is done in the query class. I just noticed now that the RunWorkerCompleted event is not being fired anymore.

View 5 Replies

Background Worker And A For Loop?

Apr 15, 2009

I have an issue that I can't seem to find a straight answer for anywhere... I have a For loop that sends a file name to a background worker that contains some long running code and I can't find a way for the parent thread to wait for the background worker to finish... Here is the example code:

For 4
BacgroundWorker1.RunWorkerAsync(fileName(i))
Next

[code].....

View 2 Replies

Background Worker In Vista Vs XP

Sep 21, 2009

I have run into this before, When I develop a form to use a background worker to fill tableadapters, the background worker does fine on machines running Vista, but if you run the same thread on an XP machine, the thread gets hung.All the thread is doing is filling a table adapter like this.[code]Why would this run on a Vista machine and not an XP machine?

View 1 Replies

Background Worker Not Working Right?

Apr 27, 2010

I have created a background worker to go and run a pretty long task that includes creating more threads which will read from a file of urls and crawl each. I tried following it through debugging and found that the background process ends prematurely for no apparent reason.

While Not myreader.EndOfData
Try
currentRow = myreader.ReadFields()
Dim currentField As String

[code]....

This first bit of code is the loop to input from file and this is what the background worker does. The next bit of code is where the background worker creates threads to work all the 'landingPages'. After about 10 threads are created the background worker exits this sub and skips the file input loop and exits the program.

Try
For Each landingPage As String In landingPages
pgbar.Timer1.Stop()
If VisitedPages.Contains(landingPage) Then

[code]....

Also my main thread runs a forms from where this background is called to run but the main thread is supposed to wait for the background process to end unless the user selects another option from the main form.

View 1 Replies

Background Worker With Several Forms

Jan 11, 2012

I've been experimenting with background worker to maintain responsiveness and to allow the UI to update while things are being done in the background.I've been having problems getting the background worker to do anything with form controls.For simplicity lets say I have form1 and form2.The background worker is on form1Initially I couldnt get it to edit controls on form1 but by using [code]However the problem came when I tried to get the same background worker to update controls on form2, in this case a text box. With the above code there is no error but it also does not update the text box.Is there an easy way to give a background worker access to multiple forms.

View 4 Replies

How To Kill A Background Worker In .net

Mar 10, 2011

i m trying to kill a background worker in the do work event of the worker i was using

backgroundworker.CancleAsync()

but its shows an error saying tat CancellationPending does not allow

how can i kill a background worker after its work gets completed in its do work event

View 1 Replies

How To Know If Background Worker Is Already Cancelled

Dec 30, 2011

currently, i have this code: My_BgWorkerB is the Name of my BackGround Worker

If My_BgWorkerB.IsBusy Then
If My_BgWorkerB.WorkerSupportsCancellation Then
My_BgWorkerB.CancelAsync()

[code].....

View 1 Replies

Pause A Background Worker?

Apr 16, 2009

Is there a way to pause a background worker? What I need to do is pause a background worker when it encounters a file error, wait for a few seconds, and then carry on.

View 2 Replies

Progress In A Background Worker

Jun 7, 2012

I have a backgroundworker which does a few tasks but I'm trying to implement a progress bar and a label. I'm going to set the maximum value of the progress bar to 10 and then have it updating as I move with each task, also I'm thinking of a label with the progress bar which will display the progress ie [code]

View 3 Replies

Run A Function As A Background Worker?

Jun 6, 2010

I have a function it is called ReLoad()

How can i run it as a background worker? so it can run in the background where it does not effect my current running function - basicly so the form will not freeze at all.

View 1 Replies

Using Progress Bar With Background Worker In VB?

Jun 12, 2011

I am developing a VB application along with MS Access... When I initially load my form I need to put my application to sleep for 3 seconds or else data wont load properly. So for this 3 seconds I would like to show a progress bar displaying a message "Please wait" I tried using background worker but did not find any success... I have gone through many tutorials but for some reason could not accomplish the task.

View 4 Replies

VS 2008 Background Worker?

May 7, 2010

I'm new for VB.Net 2008. I am facing some problem about how to make the multiple groups activities running (it might concurrent) based on their own activity's time set? For example: If there is 80 groups and 100++ activities in each group, can i use background worker (create 80 background worker?) to handle this (each background worker handle their group activities.) if in this case (But it will running lag or hang)

View 14 Replies

VS 2010 Using A Background Worker?

Nov 10, 2011

I want to use a background worker control in my application, and have it report progress to a Progress Bar It will download data and stuff, and I want to be able to change the text on a label.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved