backgroundworker

Background worker attempt

ⅰ亾dé卋堺 提交于 2019-12-12 02:39:01
问题 This is how the function was originally: void fillLiguanea() { items = new List<string>(); this.liguanea_Lane2TableAdapter.Fill(this.pharmaciesDataSet3.Liguanea_Lane2); try { string connectionString = "Data Source=LPMSW09000012JD\\SQLEXPRESS;Initial Catalog=Pharmacies;Integrated Security=True"; SqlConnection con = new SqlConnection(connectionString); con.Open(); string query = "SELECT * FROM dbo.Liguanea_Lane2"; SqlCommand cmd = new SqlCommand(query, con); SqlDataReader dr = cmd.ExecuteReader

cannot get progressbar animation with code, progresschanged not called

微笑、不失礼 提交于 2019-12-12 02:18:00
问题 i'm trying to do the code here http://www.dotnetperls.com/progressbar Here is the code I have. I've drawn on a backgroundworker, and programmatically added a progress bar. I've tried stepping over the code, and i've tried using messageboxes to see what is going on, and it looks like it is only executing one iteration of the for loop, which is for when i=0, and it seems it goes from that, to te done procedure, and the Progress procedure never gets invoked. And the progress bar never changes

Async Update ItemsControl Inside of a Datagrid (or suggest a better way)

孤街浪徒 提交于 2019-12-12 01:52:53
问题 I have a datagrid bound to an observable collection. Each item inside of the grid can have multiple detail lines, which are stored in an observable collection property inside of the main object. The line details are being fetched from a linked server with a slow connection, so I'd like to put a background worker in to update the line details OC, but I get an error saying that the control can't be updated outside of the thread that made it. What's the best way to do this. The 2 second lag is a

Invoking a control from backgroundworker stops with no error

匆匆过客 提交于 2019-12-11 23:06:32
问题 I'm running a BackgroundWorker which suppose to update my UserControl . I tried Invoking after checking InvokeRequired property: private void bgwHighlightText_DoWork(object sender, DoWorkEventArgs e) { tmpRich.SelectedRtf = myRtf; if (_ucResultRich.InvokeRequired && _ucResultRich.rchResult.InvokeRequired) _ucResultRich.Invoke(new Action(() => _ucResultRich.rchResult.Rtf = tmpRich.Rtf)); // Debug pointer stops here //Rest of the code } I also tried to invoke the RichTextBox inside my

Update textbox to a different form from backgroundworker

寵の児 提交于 2019-12-11 21:46:31
问题 I have two forms, Form1 and Newform. Form1 has two buttons and a textbox and Newform has its own textbox. I am using a settext sub to invoke a delegate sub in the backgroundworker to update the textbox in both forms. The textbox in Form1 seems to be updating but the textbox in Newform isn't updating. Is there something that I'm missing if I want to update the textbox on a different form? Thanks in advance. Imports System.Threading Public Class Form1 Dim stopbit As Boolean Dim TestingComplete

Closing a wpf window created on a different thread from the background worker WorkRunCompleted

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 21:14:03
问题 Hi there is a follow up to another question here Here is the summary In a wpf application in c# I had a long process of updating a remote database. to do this I created a background worker. However I wanted to have a window open and a progressbar run during the database update routine. All my attempts to achieve this on my main window with a progressbar set to Indeterminate failed as the "swishing" effect on my progressbar did not start to run on my main window till after my background worker

BackgroundWorker in Silverlight ViewModel

南楼画角 提交于 2019-12-11 19:09:23
问题 I have a TabControl in a Silverlight View and I'm loading Tabs by binding its ItemsSource to a TabItems ObservableCollection in my ViewModel. To open a new tab, it takes a little while to create it and load it and I want to run a BusyIndicator meanwhile. As they are created and loaded in the ViewModel, it doesn't show up if I set IsBusy property before calling the "load" method because it's not asynchronous. I've tried to set it in a backgroundworker but it crashes when I create the TabItem

Converting a Console Application into a GUI that uses a BackgroundWorker

拥有回忆 提交于 2019-12-11 17:53:18
问题 I am converting a console application into a Windows Forms Application and a DLL. The Windows Forms Application uses a BackgroundWorker to have the DLL perform a computationally heavy task. Left over from the console application, the DLL is still littered with Console.WriteLine() statements. I would like to direct what used to be printed to the console into a TextBox in the Windows Form. Ideally, I would like to hook a stream from the DLL up to the text box during form initialization and be

Updating DataGrid From a BackGroundWorker

拥有回忆 提交于 2019-12-11 17:53:13
问题 I hava a Background Worker and a DataGrid in my c# Application. In do work of my Backgroundworker which will call an Api in my dlls which will enter some Data in a SQLite Database. After the Completion of my Api call I report a progress and In progress event of my Backgroundworker I get the contents from Db and assign it as a DataSource to my grid. I call same API in same backgroundworker. In the middle of processing my application crashes. But If I dont assign the dataSource in

Updating a listbox binded list in a cross-thread in c#

自闭症网瘾萝莉.ら 提交于 2019-12-11 16:46:30
问题 My question if kind of a two parter. First of all, i have a list of student id's that is constantly added to and removed from within the program. How can i have it so that only the current items in the list are displayed in the listbox. So for example, if i have three id's and i add one, the listbox shows 4 automatically and similarly if i take one item away from the list, the listbox shrinks by 1 entry automatically. Secondly, all this adding and subtracting to the student id list is done