Updating A ListView From A Second Thread?

Aug 5, 2010

I am writing a basic application to provide remote support to multiple computers over a TCP Stream. For example, if my brother/dad has an issue with their computer, rather than going over to help them I can just use remote support (Yes, I know Windows has Remove Desktop, and their is TeamViewer, ect. But where is the fun in using those =P)Anyway, it basically works by taking a PrintScreen of their computer, sending it to mine and displaying it in a PictureBox, then when I click the image, it records the coordinates of my mouse, sends it to theirs (Little Maths for resolutions and positions ofc) and clicks, then sends a new image.

My problem is, I want a ListView displaying the PC Info, like:

PCName - RAM - Free HDD Space - 32/64Bit - Processor Speed

Now, my problem is, I have a Class which does the TCP Server, and in that class when it Receives a Message, it calls the Sub "RunCommand(ByVal Command As String)", which then splits the String and works with it.So, for example, their PC would send the String "Info|DadPC|2GB|235GB|32Bit|2.2GhZ|" And mine would split it, and add that data accordingly.However, what happens is, nothing. If I put in "MsgBox()" anywhere in the Code, it shows it is all Split, and received correctly and everything is fine, but no matter what happens, it wont add to the ListView (Or anywhere else on the form, for example "GUI.Text = Info(1)" Wont work either)?

View 8 Replies


ADVERTISEMENT

VS 2008 Updating A ListView From A BackGroundWorker Thread?

Sep 20, 2009

I'm using the following to check the state of checkboxes and then activate some public subs based on the checked state of the checkboxes:

vb.net
Public Sub TestSub() If Me.CheckBox1.InvokeRequired Then Me. CheckBox1.Invoke(New MethodInvoker(AddressOf TestSub)) Else Begin() End If End Sub

Within the Begin sub, I have code that performs specific actions and then updates a ListView with that information.As far as I can tell, the actions are being performed, but the ListView isn't being updated with the info.I'm calling the Test sub from a seperate form, within the BackGroundWorker's DoWork event.Would I have to check the InvokeRequired property of the ListView as well?I'm looking more into the documentation of the BackGroundWorker.

View 8 Replies

Forms :: Thread Cannot Access Another Thread's Member Directly And UI Updating

Oct 18, 2011

I have a small problem that I am sure is due mostly to my inexperience with threading. I have used simple entirely self-contained threads before, but not to a great extent. I understand the basic laws that surround them, such as how a thread cannot access another thread's member directly, and must use delegates.

[Code]...

View 1 Replies

Updating UI From Another Thread

Dec 14, 2011

We have an issue with an application where we are making a call to an asynchronous process on LostFocus of a TextBox, the asyncronous process then needs to be able to update the main form UI (or display a dialog from the main form UI) while running asynchronously.We have thought about call backs and having it truely asynchronous but we need everything to execute in the correct order and this is for a data entry system where speed and accuracy of data entry is important.Example code shows what we are trying to do and if you switch to Begin Invoke the order of processing is not correct.[code]Does anyone know how we can invoke something else on the main form thread while is is still busy processing the LostFocus event?

View 2 Replies

Updating & Getting Values From UI From Another Thread?

Aug 25, 2011

The program i am writing has 5 features, all of which i want to run in their own threads. On the main for I have a listView which contains all the accounts (user password etc). The thread is defined as:

Public fbaThread As New Thread(New ThreadStart(AddressOf fba_Start))

In cmdAdderStart i begin the new thread by:
fbaRun = True
fbaThread.Start()

[Code]....

I have managed to write the UpdateDebug() to update my txtDebug on the main form. But now I am having trouble being able to pull the values from lvAccounts.items().subitems I can accomplish this with global variables but i'm sure this is not the best way to do this.

View 5 Replies

Updating A Form From Different Thread?

Jun 13, 2010

I have a VB.NET 2010 app I am writing that does a lot of work on a RS485 bus in 2 seperate threads. These threads are started as soon as the app is opened and run as long the app is open. I would like to have the threads update labels on the main (and only) form every so often based on what's happening on the serial bus. I know it involves invokes and delegates but I haven't found a straight forward answer on how to implement it.

View 5 Replies

Updating A Textbox From Another Thread?

Feb 7, 2010

I have been trying to update a textbox on the main form of my program using a different thread, however the changes are not relected in the textbox.I am using MS Dev studio 2010 beta 2.0 .NET 4.0. Here's my code....

The main form

Code:
Public Class frmMain
Private Engine As New clsEngine
Private txtMessage As String

[Code]...

View 2 Replies

Updating Controls In A Thread?

Dec 28, 2011

I've got a bunch of labels that I update regularly in the program, resulting in lagg, which is bad, so how can I update the labels in a thread?

When I try

Thread = New System.Threading.Thread(AddressOf ShowInfo)
Thread.Start()

[Code]......

View 3 Replies

Updating UI From Worker Thread

Oct 27, 2009

This is slightly different to just updating a UI from a worker thread. The object which calls the thread, calls another object, and it is this object which is is trying to update the UI. It doesn't however work.

Imports System.Threading
Public Class Form1
Public Delegate Sub GetText(ByVal sText As String)
Public GetSomeText As GetText
Public Sub New()
' This call is required by the Windows Form Designer.
[Code] .....

View 5 Replies

Avoiding Updating A Form From A Thread?

Sep 8, 2009

I've seen a good bit written on avoiding updating a form from a thread.However,I was wondering if that was a problem if the thread exists in an object that programatically builds the form?Thus the form and associated logic exist within the same "thread space." Seems on the face of it like it would work since everything in the form should be in a single dispatch queue.

View 8 Replies

VS 2008 BackgroundWorker Thread An Updating UI?

Apr 3, 2010

I'm running some tasks on a BackgroundWorker thread and needed to display the current tasks in a label.Before adding the label, the tasks were completing just fine and the UI was responsive.Once I added the labels, the UI has become unresponsive. The issue, I believe, is the Invoke property.I've declared all my tasks, including the updating, in a sub and am getting the Invoke property of the label each time, in order to set the information.The following is an example of what I'm doing:

VB.NET
Private Sub Test()If lblTask.InvokeRequired = True Then Dim mi As New MethodInvoker(AddressOf Test) lblTask.Invoke(mi)

[code]....

View 7 Replies

Control Not Updating From Cross Thread Call

Oct 10, 2010

I have a few classes. One of the classes handles everything to do with updating controls (Such as adding items to a listview, etc.) and another is handling loops. I'm trying to add something to a richtextbox from another thread.[code]..

View 3 Replies

Copy Directory In Thread & Updating Progressbar / UI?

Mar 24, 2010

I have got this module which copies a specific folder and all files inside it.[code]...

View 8 Replies

Cross Thread Operation Not Updating Control

Apr 28, 2010

I have some controls in a .net 4.0 form - a listbox and a listview item.I also have another thread in the same class which is checking a host for output.It uses delegates to display all incoming data to a richtextbox - this works fine.If the data has a particular signature it sends it to a parser sub in another module.This module tries to update the listbox and listview items with that data after it has manipulated it.The problem is; no data is displayed and no errors are thrown.If I add a msgbox("Test") after the code, it shows the messagebox.If I add a test messagebox inside the delegate function, it shows the messagebox. If I put the same MainForm.ListBox1.Items.Add("Howdy") in a ButtonTest.Click event it adds it correctly.

View 14 Replies

Forms :: New Thread Versus BackgroundWorker Updating UI

Aug 24, 2010

i have lurked on these forums before and finally signed up..i have a situation that, after days of searching the web, i have not been able to come up with a solution for.i have to fire off a function that takes a large amount of time (writes to database, creates files, etc etc)this function is a non-shared function of a class. if need be i could make it Shared.[code]the code works great, but what i need to be able to do is update a form with a progress bar as the job is processing.all of the examples i have seen that do this are being called from within a Windows Form and they access the form directly - i cant do that in this case. my form needs to be 1 form for 1 job being executed - can process multiple jobs at one time and thus i need multiple forms.i have tried making the form part of my delegate class but since it runs in the same thread the effect is it "freezes" until the job is complete.i have just started looking into using a background worker but again, all examples i have seen use the component as part of a form - that wont work for me.

View 3 Replies

Forms :: Updating UI Label From Another Class In Another Thread?

Nov 2, 2011

I've been programming in vb.NET for a whileAnd to be honest, its turning out to be a real pain.Here is the

Form1.vb: Imports System.Threading
Public Class Form1
Dim trd As Thread[code].....

So, I have a form (form1) with a label on, this label simply reports the status of the thread.The thread begins the Class1.Main() sub, and I have a delegate setup to change the text propoerty of the label.Now,I know the label is created on the UI thread,so I assumed the delegate would work. However,it seems that it updates the .text property, but doesnt redraw the control when .Update() is called .What am I doing wrong?I have found lots of examples of delegates, but all run from within the same class. I want to use threads too, not a backgroundworker! This code is a "simplified" version of a project I am on, which is encountering the same problems

View 17 Replies

[2008] Updating Form Variables During Thread?

Sep 1, 2009

I'm not sure exactly how to describe this. In VB6, there was a Timer command. I could create a variable of type Timer and loop until the current value for Timer exceeded the initial plus a given amount of time. This allowed me to update form variables while the timing loop was executing. How can I do something similar in .NET?

Here is a sample of the VB6 code:

Code:
Dim StartTimer As Double
StartTimer = Timer
Do

[code]....

View 2 Replies

Error When Updating The ProgressBar Control When Accessin It From Another Thread

Mar 8, 2010

I have a windows form with a progress bar and a button to start/stop the process. I am performing some action when clicked on 'Start' and updating the ProgressBar accordingly and its working fine. But when I try to click on the 'Stop' button when the process is going on, I couldn't access the Window. If I click for multiple times, I am getting (Not Responding) on the titlebar.

Then, I created a thread and run the function (which performs my task and update the ProgressBar) in it. I am getting an error that it could not access the control which is created in another thread.

View 2 Replies

Updating A Form From A Background Thread, Started In The MyApplication_Startup Sub?

Nov 17, 2008

I'm having some problems with updating a form from a background thread, started in the MyApplication_Startup sub.As far as I know updating forms or controls on forms have to be done threadsafely.

When the application starts up, some threads are being created which create an object in which a download for a zipfile will be started. The object has some delegates to let the GUI know what the status of the download is, for example 'started' or 'finished'. Also the mainform will be shown on which a datagrid has been placed to show the user which files will be downloaded and in which phase the download is.

All this works amazingly fine but when I want to update the datagrid's cells p�r thread the datagrid aint updated. I know the problem is that the thread in which the Form is created isn't the same as the thread which wants to update the grid?

View 4 Replies

Updating Label.text With StandardError.readline In A New Thread?

Jan 14, 2011

Private Sub runExe()
Dim myProcess As New Process()
Dim myProcessStartInfo As New ProcessStartInfo("mkclean", " --optimize """ & txtSrcFile.Text & """ """ & txtSaveFile.Text & """")

[Code]....

View 4 Replies

Updating Screen With Messages From Thread That Raises Events

Dec 21, 2010

I have a very long running process that I start in a thread. This raises events with messages to say what it is doing. How can I update a label on screen with these messages? (The label is in an update panel if that makes it easier).

View 3 Replies

Visual Studio - Cross-thread Communication And Field-updating

Jan 24, 2011

I'm having some trouble getting cross-thread communication/field-updating working properly in my VB.NET 2010 program. I'm trying to update a field on my main form whenever a thread that I've started throws an event. Here's a simplified version of my code:

My main form:

Public Class Main
' stuff
' Eventually, startProcessing gets called:

[Code]....

View 1 Replies

Populate ListView Using A Thread?

Jan 22, 2012

cedure that populates a ListView, but it does a lot of work and it takes too much time to display all it's items (about 100-200 items). I want to use a thread to display the items as it's extracting data (real-time).I posted a question earlier here, but using a ListView it's not working for me...

Imports System.Threading
Imports System.ComponentModel
Public Class Form1

[code].....

View 8 Replies

Using The ListView Control From A New Thread?

Apr 19, 2010

Would someone mind explaining to me how visual basic treats a ListView object? It seems that if I create a new ListView and make it equal to the old ListView it's like filling the new ListView "ByRef" so to speak.

I'm running into problems because of this when I try to do some processing with the selected items in a new thread. Does anyone have a better solution to this than using a delegate to call a fucntion which populates an ArrayList with the ListView.SelectedItems and then returns the ArrayList?

Edit: Seems no-one is answering well let me ask a "hopefully" easier sub-question.

If i'm trying to pass a ListView into my BackgroundWorker as an argument, how do I successfully do that? I've heard someone say "make a copy". Yet I still get cross thread exceptions on my e.Argument. Tips, tricks, musings, all very welcome.

View 6 Replies

VB 2008 - Thread And Listview

Mar 2, 2012

the below code is on a form2..but the listview it must add these items to is on the Form1. I had to use a delegate just to get it to check if a file contains a specific Character. to add 1 to the lables as number of manuals found Everything seems to be be working except it isnt adding items to the lisview, correction. i think everything is working ok and it's not adding items to the listview. I'm trying my best to understand the thread process, but thus far all i get is confusion,when something does'nt work. add items from form2 to a list view in form1 using threading [Code]

View 10 Replies

Iterate Over A Listview In A Background Thread?

Aug 16, 2011

I've got an application with a ListView and I want to loop through each item in the ListView. But I want to do this in a separate thread.

This is a very simple version of the code - but its error is the same:

Private Sub StartToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles StartToolStripMenuItem.Click
pingThread = New Thread(AddressOf loopingRoutine)

[Code].....

View 2 Replies

VS 2010 Populate ListView Using A Thread?

Jan 22, 2012

I have a procedure that populates a ListView, but it does a lot of work and it takes too much time to display all it's items (about 100-200 items). I want to use a thread to display the items as it's extracting data (real-time).

[Code]...

View 7 Replies

Updating Listview: Lags At 60+ Entries Being Added?

Jan 21, 2012

The scenario is i get a string sent to me that i split by a space. Any thing under 60 count when the split occurs it's fine. After that i have a problem.Now there is a lot that needs to happen before we can add this newly split array to the listview.First we need to check what the name starts with. Then assign an icon to this nick.When my server class gets sent this string. Raw Numeric 353 channel names i then send it to my nicklist class.

vb
Private Sub InitiateThread(ByVal nicks As String) Handles _server.NameListEventArgs
Dim thread As New Thread(DirectCast(Sub() DoWorkChannelNicks(nicks), ThreadStart))
thread.Start()
End Sub

Then we split the string and loop each item

vb
Private Sub DoWorkChannelNicks(ByVal users As String)
Dim nicks() As String = users.Split(" "c)

[code]....

how to speed the process up?

View 9 Replies

.net Thread Safe Method To Add A Listview Subitem?

Feb 21, 2011

I am trying to add a subitem to a listview in a threadsafe manner.In a single threaded application it works like so:

[Code]...

However if run in another thread it causes a cross threading error.I have looked at examples of delegate subs that use Invoke, but all examples i have seen involve updating the text property of an object, and i cant get my head round how to apply the concept to actually add a subitem to a listview.

View 3 Replies

Adding Items To ListView In Separate Thread?

Jan 26, 2010

For some reason, the following code is causing me some issues. This code pulls lockout status data from AD and contains the data within a datatable. An event is raised from the threaded procedure to add the data to a listview control. For some reason one row of data gets added to the listview control and when you run the procedure gain, 2 rows of the same data gets added, and then 3 rows, etc.

This code calls the procedure "CallGetUserLockout"
GetLockoutStatusToolStripMenuItem.DropDownItems.Add("For Current User - " & User, Nothing, AddressOf CallGetUserLockout)

[code].....

View 3 Replies







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