VS 2005 Class Api Needs To Get A Handle On Form Elements In The Main Worker Thread

Sep 4, 2009

I have a standard windows application called winap. I have a com component which acts as an api to the winap. I have a class in winap call classapi which has all the methods that the api calls and all works well. The problem is that one of the methods in my class api needs to get a handle on form elements in the main worker thread. Whenever I try to access an existing form I keep getting null because the for exists in the main worker thread and my api call is in a seperate thread.

[Code]...

View 5 Replies


ADVERTISEMENT

Write In Worker Thread In A Data Table And Rich Text Box in Main Thread

Mar 4, 2009

I'm creating a Client Server application which involves theServer running some scripts in clients and getting back results in an automated way. In Server, other than Main thread, i have 2 worker threads, a) one monitoring response from clients and b) the other scheduling next available job to respective client which executes that job. The issue here is ,I want these worker threads to write the status of their work in the UI(which comes under Main Thread). Also i need to write things in worker thread in a Data table and Rich Text Box in Main thread. But, I can't do so, since it has been blocked to access one thread's function or property directly from others. Is there any work around to do this?

View 8 Replies

Handle Events From The Main Form In A Separate Class Or Module?

Feb 24, 2012

I've been searching for the answer for a while but can't find it yet. Basically so far I have a simple VB.Net form with one button.I would like to make a class or module that can handle events from the main form. This is my code so far but it doesn't seem to work.

View 6 Replies

C# - Background Worker In External Reference (DLL) Locking Main Thread?

Mar 21, 2011

I use background worker almost daily and works great. Today I came to an instance though where I needed to put my background worker in a separate project then the one I was running because I needed to use this class in two different projects in my solution. When I tested the coding on a winforms form, it works perfectly, handling my coding on the background thread. When I try to reference this class from an external project, all of my coding seems to run just fine, but it does not appear to be doing anything on a background thread as it should be, causing my main window to lockup.

Is there any way around this / what is the best practice for ASYNC calls in an external class.Note I basically created a class that u call start, and an event fires when data is ready, so it's not like my external project is waiting for the method to complete.

Solution ABC has two projects. Project A and Project B. Project A is my WPF application and B is my DLL doing the work. Inside project A I have

Dim SmartCardData as new Solution.B()
SmartCardData.Start()
Project B has a sub

[code]....

View 3 Replies

Create A New Instance Of Webbrowser Class Inside Of A Worker Thread?

Jan 14, 2009

Is it possible to create a new instance of the webbrowser class inside of a worker thread?

View 2 Replies

Update UI Form From Worker Thread?

Oct 20, 2010

I am new to multi-threading in VB.NET and have come across a problem whereby I am wanting to append text to a text box on a form from a service thread running in the background.

The application I am developing is a client/server listener, I have been able to get the client and server PC's to talk with each other (confirmed through MsgBox), however I am now struggling to get the service thread on the server to append the text to the textbox, nothing vissible occurs.

I have a form named testDebug which calls a class (RemoteSupport), this class does all the handshake tasks and updates the textbox with the connection data.[code]...

View 2 Replies

Background Worker / Progress (Report To Default Instance Of Main Form)

May 23, 2012

I am using background worker to report progress on the screen. In the Main.vb I have the following

Public Sub report(ByVal sender As System.Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles bwlistener.ProgressChanged
Dim message As String = e.UserState
logRTB.AppendText(message & vbCrLf)
End Sub

When I call this from Main.vb I use:
bwlistener.ReportProgress(0, "Some status text goes here")
It works great. The problem is when I try to call it from any other module in my project.

When I call it OtherFile.vb:
Main.bwlistener.ReportProgress(0, "Some status text goes here")
It doesn't work... The program doesn't crash. Debug goes through everything but no output is actually shown to the end user.

View 16 Replies

Load The Main Form Of A WPF So That A Separate Thread Goes And Gets Data From The Database While The Form Is In An Apartmentstate?

May 15, 2012

How do i load the Main form of a WPF so that a seperate thread goes and gets data from the database while the form is in an apartmentstate? (drag-able / movable) I Know this is possible with opening a new window from your main form like this :

Private Sub openOrderWindow()
Dim OrderWindow As Orders = New Orders
OrderWindow.ShowDialog()
End Sub

[code]....

I've tried putting MyBase.ShowDialog() and .Show() and .9000+ other things The only benefit I've got out of using a seperate thread to load from the databse is i can see the screen right away (as oppose to it being a transparent box until it loads) but i cannot move it around or minimize it?is there any way to make it Movable while it loads?

View 1 Replies

Forms :: Main Form Minimized After Opening Form In A Different Thread?

Jun 7, 2009

In the main form the user can choose to download information from a device.Since this request takes time, when "download information" is pressed I open new form in a separate thread: Private Sub RunDownload()

[Code]...

View 3 Replies

Handle Events And Notifications From Multiple Sources To A Main Form In .net?

Sep 23, 2011

I have a vb.net application in which there is a main form. There are around 10 classes each having their own functionalities like tcpactions, fileactions, serialport actions etc. The user interacts with the main form and does certain actions which will invoke the methods in these classes. Now I have a notifications textarea in the mainform and i want to show the current action being performed in those classes and their results in the notifications area.

for example when a user clicks a "Start Process" Button in the form i invoke the method "launchprocess" in a class "ProcessActions". Now this method tries to launch about 7 different process and after launching it sends notification such as "process 1 launched" or if it fails it sends notifications such as "process 1 launch failed".

I currently use event handlers and use them to show notifications but with the amount of events i have to handle it is getting cumbersome and i might have to add even more classes in the future. So is there a better way of handling notifications from other classes.

View 1 Replies

Access Progress Bar On Main Form From Thread On User Control?

Aug 18, 2009

I have a windows application with a main form, on which a user control is added dynamically when a device connects trough USB.

On a user control, there is a thread wich is getting data from the device trough USB and when it is finished, I want to change a progressbar that is located on the main windows form where user control reside.

This is the code that is I call on the user control thread to change the progress bar value:

Frm_Main.UpdateProgressBar(CInt((AllBytesReceived / MaxBytesInFlash) * 100))
and this is a code that is called on the main form:
Private Delegate Sub UpdateProgressBarDelegate(ByVal value As Integer)

[Code]....

View 8 Replies

Forms :: Access Main Form From Second Thread Running In A Module?

Jun 22, 2010

I was a vb6 user, done a few projects only with forums Now i am moving to vb.net(vb2010) and i have some trouble.Lets say we have a form(form1), a module(mod1) and a textbox on the form1.

i want to start a Sub (DoWork) in the module but in a new thread.

Dim Thread1 As System.Threading.Thread
Thread1 = New Threading.Thread(AddressOf mod1.DoWork)
Thread1.Start()

The DoWork sub does some stuff and when it's finished i want to change the text of a textbox1 in the main form and start another sub (DoWork2) on the main form under the main thread not the one DoWork is running under.

Plese do not refer me to another post that mighe give me a part answer, try to explain to me what i have to do and why.

View 3 Replies

Creating A Progress Bar That Runs On Another Thread While Keeping Calculation In Main Thread

Nov 12, 2009

Preface: I know this is an unusual/improper way to do this. I can do this with a "real" ShowDialog(), background worker/thread, and so on. I am trying to do specifically what I describe here, even if it is ugly. If this is impossible for X reason, I have created a fancy progress dialog for some of our long running operations. I need to have this dialog shown on a new thread while having processing continue on the calling (UI in most cases) thread.

[Code]...

View 3 Replies

Thread State - Thread In An Application Which Calls A Sub Routine Main()

Jul 26, 2010

I have a thread in an application which calls a sub routine Main(). The Main sub routine in turn call several sub routines/functions from with the same module,several different classes in the same application. Also some sub routines/functions call routines from a class library. Now say the routine/function in class library goes into a infinite loop and never returns. I would like my thread in the application to raise a event and display message to the users about the infinite loop. I am giving some sample code for the application.

Imports System.Threading

Module VMain
Public gbSuspend As Boolean

[CODE]...

View 7 Replies

Access Objects Of Main Thread From BackgroundWorker's Thread?

Aug 4, 2011

I'm working with BackgroundWorker, I want the BackgroundWorker do the retrieval process of data from database while the user can still do another task on the form. The problem is, after retrieving the data, I can't seem to access the ListView in my Form from the DoWork event of BackgroundWorker, I will populate that ListView using the data I've retrieved.

Consider this example, this is how I'm doing it:

Public Class Test
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

[Code].....

View 1 Replies

How To Call A Class From A Main Form

Mar 5, 2010

How would you call a class from a main form? In VB6 you would call a module by just simply calling the module name.

View 2 Replies

Class Not Registered While Loading Main Form

Apr 1, 2009

We have a Dell laptop used to run an in-house VB.NET program. It got a virus. We had to wipe the hard drive and reinstall Windows from scratch. We use Windows XP Pro, which is what was installed on it before. But now our VB program won't run. After trying and despairing of getting remote debugging to work, I actually installed Visual Studio 2005 on the machine, just long enough to get information about what was making the program fail. And the failure was most peculiar. It isn't in our code. It's in the VB setup code that loads the main form. And it says, "Error loading form: class not registered."The gory details are given below. Now here's the strange thing. Not every VB.net program fails on this computer. And the program that fails, fails only on this computer; it has run successfully on several other Windows XP systems with .NET Framework 2.0 installed.[code]

View 3 Replies

VS 2008 Can Call A Class From Main Form

Dec 14, 2011

As of the moment I have 24 buttons that are keys to a piano.24 of the button codes have a call method that calls the note to be played.24 of the private subs that are called have an .wav audio playback command within them. I was hoping I could move the .wav private subs into a separate class, and just call them from my main form, therefore cleaning up the lines of code I have at the moment. [code]That example only counts for one Button "The Key of C", and the audio file that is called with it. Multiply that by 24 and you get a big mess of repetitive junk.Can I move the audio subs into a class and call them from my main form?

View 16 Replies

Fire An Event In Main Thread From Another Thread?

Sep 24, 2009

could someone tell me how to fire an event in main thread from another thread as well as fire and forget without use a new thread?

View 9 Replies

Run A Method On The Main Thread From A Separate Thread?

Dec 31, 2010

I'm reading data from a serial port, but the DataReceived event of SerialPort is handled on it's own thread. I want to handle this on the main thread, but simply declaring an event and raising it still results in it being processed on the SerialPort thread. I'm assuming I need to declare a delegate I can call, but I don't see how that would work.

For example, I want to call Sub HandleDataReceived() on the main thread from the DataReceived thread, having HandleDataReceived() run on the main thread. How would I do this?

View 1 Replies

Accessing Function In Alother Class From The Main Form?

Feb 12, 2011

I have a new solution with 5 projects inside. a data access layer, database, 2 class libraries, and the main form. These are all components that I had worked on to get to this point of combining into 1 solution. Now what I have run into is I can not the actual functions in the class libraries. I can get to the class level, but that is it. ere is a sample line of code I need to get working. Once I get this one line, the rest will be obvious: Temperature is on the main form. get for options is "Equals, GetHashCode, GetType", etc... Before this I had bult, compiled, and referenced these classes separately, and it worked fine. I know this is going to be an easy answer, I'm just not seeing it for some reason.

View 15 Replies

Use Form Handle In Class Without Pass It As Argument?

May 3, 2012

I'm writting a class that needs the form handle but there is a way to use it without send it as argument in the class constructor or in a property?I know that the handler is not set until the form is completely loaded so that is another problem too.The basic idea is catch the form handle without pass it as argument and handle the wm messages.

View 2 Replies

[2005] How To Use Bindingsources From Main Form On Dialog Form?

Mar 2, 2009

My project has a single dataset with about 6 datatables. Each of those datatables has a TableAdapater and a Bindingsource on the main form (due to various databound controls).

Now, I want to have a second form for adding a new record. If I bind the controls to the datasource it creates new TableAdapaters and new Bindingsources on that form. I was wondering if it's possible to simply use the ones from the main form instead like this

[code...]

View 3 Replies

Error On Worker Thread

Dec 27, 2009

I have some class that splits some work onto multiple worker threads. To be more specific: the class represents a download, that can have as many segments as the user wants, that get then put onto separate threads.When I run the download with one segment, it works fine. When I run it with 2 segments, the second segment encounters an error.[code]When I put a breakpoint on the if, it'll stop there, but when I go to the next line, I get an error.I don't get what's getting wrong, and got a headache after a few hours of attempting to keep track of the correct thread.Anyone an idea what's going wrong, or how I can detect it better? (This is the first time I'm doing real multi threading debugging.

View 4 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

C# :: Co-ordinating Worker Thread Shutdown?

Nov 1, 2011

I've got a List(Of IWorker) which contains a number of concretes. IWorker in turn has a Startup() and Shutdown() method.Inside the Worker class, Startup() creates a new worker thread then returns. Shutdown() presently sets a private ShutDownRequested flag and returns. The flag is checked by the worker thread (at worst every few seconds).This all works fine but at present the parent app has no way to determine if the Worker has finished shutting down.I can see a number of ways around this but am not sure what the best one is.Add a State property to IWorker. Should work but I'm going to be polling states which seems a little nasty.Make the shutdown command blocking - Would probably be my ideal solution but I'm not sure how to implement it - does the worker Sunclock a private object which Shutdown() should also try to Synclock after setting the flag?

View 3 Replies

Cannot Access Controls From Worker Thread

Aug 24, 2009

Here is my setup:

Form1.vb - contains RichTextBox1 and BackgroundWorker1, which calls a the Control module.

Control.vb - calls Display module.

Display.vb - calls Form1.SetTextBoxText("text here").[code]...

My observations: When the Display module calls SetTextBoxText, InvokedRequired's is false. Also, if the BackgroundWorker1 (which is in Form1.vb) calls SetTextBoxText, it works. But if BackgroundWorker1 calls a module that calls SetTextBoxText, it doesn't work.

View 4 Replies

Serial Use Of A Background Worker Thread?

Apr 6, 2012

I have a BackgroundWorkerThread which I want to use serially.So some of the code in the UI thread will look like this [code]But of course I can't do the second RunWorkerAsync until the UI thread has seen the RunWorkerCompleted event indicating that the "Sequences" work has been completed (or somehow knows that the "Sequences" work has been completed).So I need some sort of synchronization between the two RunWorkerAsync calls, but whatever I use cannot hang up the UI thread because it has to be able to handle ProgressChanged events.Maybe the RunWorkerCompleted event could make the second call but I really don't like that structure.So how do I delay the second call to RunWorkerAsync (for the "Templates" work) until the background thread has completed the "Sequences" work?

View 6 Replies

VS 2005 Main Form Resize One Dimension Only

Oct 21, 2010

My program displays nature pictures so I want to restore the original ratio on wide screens when the form is first normalised. In the form resize event (inside a flagged section to avoid looping) I have

[Code]...

For some reason the resize event is only triggered once and only the width gets set. If I change the order only the height gets set. how to make it change both?Actually I wouldn't ever need to change both if not for a small but annoying little problem on normalising. Rather than fit the available screen height it always seems to be a bit more, as if the top border height is added to the existing max height. This seems to be a .NET bug.

View 10 Replies

Background Worker Create Second Thread For Progress Bar?

Apr 6, 2011

I have searched the forum and found several forums related to the backgroundworker thread but have been unsuccessful in finding my answer.My objective is to display an animated gif or progress bar while the program is executing a particular method which can take upwards of several minutes to complete. I cannot get the second thread to run the progress bar while the main progrem is executing the time consuming method. I have created a demo based on another thread and can't seem to get it to create two threads. I was attempting to get the backgroundworker to execute the progress bar while my main code runs on UI thread.

[Code]...

View 10 Replies







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