Use Backgroundworker In A Class And Generate Events For Client Application?

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


ADVERTISEMENT

.net - Responding To Application-killing Events During Class Initialization?

Apr 6, 2009

When starting my application, I have a couple of classes which are required to read certain files in order to create a set of default data. The logical place (to me) to do this is in a Shared class constructor; the idea would be to throw a class-level event if the reading of the defaults file fails. Unfortunately, this does not work as attempting to access such an event, in order to attach a handler to it, fires the class constructor before the event has been attached. In a failing case, the constructor starts, fires the fail event, the constructor completes, and then the event handler is attached, after the event has fired.

The only other solution I can think of is to give the class a "typeInitialisedSuccessfully" boolean property and put a try/catch block around every call to construct an instance of the class, which seems unnecessarily kludgey to me. Can someone suggest a more elegant solution?

EDIT: Because this is a fundamental Class, used in one form or another across nearly all of our software tools, I would greatly prefer a solution that will notify future programmers that the type initialiser needs to be called, which is why I initially went towards the Shared Constructor as a solution.

View 1 Replies

Use Backgroundworker For Generate Query And Fill Datagirdview?

Dec 12, 2011

my query is too long and retrive larg data.

and myform hanged when query is process.

View 5 Replies

Backgroundworker Runs A Object's (with Events) Method

Dec 19, 2010

I have a class that is used as follows:

Create an object

Run the RunIt method

The object runs some code and sometimes raises Event1 and sometimes Event2

I want to run that object using Background worker

Programming the app I wasn't sure of the code so I created the VS project shown below so I could make this post

Many questions:

Which routines in the code are run on the worker thread?

Is the object created on the worker thread?

And are its events run on the worker thread?

How to handle the Cancel. The way I did appears tp work except that

e.Cancelled does not return as true (Done is displayed).

And suppose the object didn't have events how would I handle Cancel?

Is there a better way to handle the basic problem?

I wish the code was shorter but wanted to be sure I prsented the problem.

Option Strict On
Option Explicit On
Imports System.ComponentModel

[Code].....

View 4 Replies

.net - Events Raised By BackgroundWorker Not Executed On Expected Thread

Mar 22, 2010

A winforms dialog is using BackgroundWorker to perform some asynchronous operations with significant success. On occasion, the async process being run by the background worker will need to raise events to the winforms app for user response (a message that asks the user if they wish to cancel), the response of which captured in an CancelEventArgs type of the event.

Being an implementation of threading, I would have expected the RaiseEvent of the worker to fire, and then the worker would continue, hence requiring me to pause the worker until the response is received. Instead however, the worker is held to wait for the code executed by the raise event to complete.

It seems like method I am calling via the event call is actually on the worker thread used by the background worker, and I am surprised, since I expected to see it on the Main Thread which is where the mainform is running. Also surprisingly, there are no cross thread exceptions thrown.

View 1 Replies

Installing An Application On A Client Machine "Class Not Registered"

Aug 20, 2009

I am installing an application on a client machine. The application is throwing an exception that I am logging that states "Class Not Registered". This an app written in Visual Studio 2005 using VB.NET. The dll dependencies of my .exe are located in the same folder as the .exe. What class is this talking about and how can I resolve this issue?

View 2 Replies

Make Every Checkbox In A Checked List Box Generate Its Own Click Events?

Oct 9, 2009

How to make every checkbox in a checked list box (VB 08) generate its own click events .

View 1 Replies

How To Make A VB Application That Can Stream From Client To Client

Feb 7, 2011

for a school project i need to make a vb application that can stream from client to client.

View 4 Replies

Backgroundworker, Use An Object At Class Level?

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

GUI Class - Logging Options With BackgroundWorker

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

.net - WPF BackgroundWorker - UI Locks Up Trying To Instantiate Object From External Class?

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

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

Modify .net's BackgroundWorker Class So That It Fires A Custom Event Upon Method Completion?

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

2005 : Crystal Reports Application Or Windows Application To Generate Pdfs?

Apr 13, 2011

I currently have a simple crystal reports application which generates a crystal report and in the built in viewer provided by VS2005. There is a drop down where you can select options to change the criteria of the report. I wish to convert this app to a windows executable which will take all those select options and generates pdfs based on the crystal report. the executable will be triggered by windows task scheduler...or maybe command line app?

Obviously this will be somewhat of a re-write. What would be the best way to start this as? a crystal report application or a windows application.

View 2 Replies

Add A BackgroundWorker To Application?

Jan 24, 2009

I'm trying to add a backgroundWorker to my application, but I can't find it.I tried looking in the toolbox, but didn't find it. I looked in the Choose items dialog box and it is checked. Tried unchecking and checking it again, no difference.

I tried using Dim worker As System.ComponentModel.BackgroundWorker but get an error:

Type 'System.ComponentModel.BackgroundWorker' is not defined.Is there any way to add it to my program?

View 9 Replies

Partial Entity Class With Shared Extension Not Associated With 'other' Partial Class In Client Using RIA Services?

Apr 21, 2011

I have extended an Entity Framework 4 entity class with a calculated property in a partial class. This member is not available on the client to which the entities are exposed via WCF RIA Services.when using C# appears to be changing the extension of the partial class file from .cs to .shared.cs. I tried this with my VB.Net solution (.vb to .shared.vb) and got a long list of errors. I believe what happened is that the partial class lost its association with the entity on the client - it inherited from object rather than EntityObject.

My best guess is that this is related to the way that VB.Net handles namespaces.Each project has a 'Root Namespace' which is prepended to anything that is defined within a code file. C# has a 'Default Namespace'which is the namespace into which new types are placed by default - via a namespace statement within the file.The partial class is probably having the client namespace prepended to it which puts it into a different namespace than the entity with which it is associated on the server.Is there any means of extending an entity in such a way that those extensions are available on the client via WCF RIA Services and VB.Net?

View 1 Replies

Can Dot Net Generate Class From Database Table

Nov 17, 2009

can dot net generate class from database table ? means if i have a 1 table & want to create class for 1 table like insert, update, delete functions & properties(for table columns)

View 1 Replies

Remote Desktop Application? Safe To Use Winsock In Creating A Client/server Application?

Jul 18, 2012

Im planning to create a Remote Desktop Application and I'm having problem with viewing other computers monitor or screen.

Im not asking for the code on how to do it. and one more thing is it safe to use winsock in creating a client/server application?

View 3 Replies

Deploying Winforms Application To Client Machines Application Failing On Start?

Jul 2, 2009

Deploying Winforms Application to Client Machines Application Failing on start

View 8 Replies

Class Library Events?

Mar 6, 2012

I`ve made a .NET component in C#. After that, i`ve created a class library in VB.NET and added this C# component and a couple of buttons to the library (creating another component now with buttons). So far, so good.The problem is: when i use this final component (vb.net class library), i want to link all MouseClick Events of its own components (buttons and C# component). In other words, when i add this final class library to my VB solution, it has its own MouseClick event. But when i click inside it doesnt raise the click event unless i do not click in the buttons or in the C# component inside it. I want to raise this event in the application wherever i click (inside or outside its own components).

View 14 Replies

Create Events For Class?

Feb 25, 2010

how to create custom events. If anyone can give me some simple sample code and/or refences,

View 5 Replies

Handle Events In Another Class

Sep 2, 2011

I'm trying to move some code into some class files to clean up my code. One area I'm having trouble with is reporting progress for events between the object performing the task and a progress bar. I guess the event functions have to be placed in the new class but they also need to update the progress bar on the calling form? Can the classobject return updates in place of the event handlers?

[Code]...

View 2 Replies

Public Class Events Not Seen Outside

Mar 3, 2009

I've got an issue where Public Events in a class aren't being seen outside the class.
Code looks like this:
Public Class Class1
Public Event Event1(someargs as object)
Public Sub New()
'Perform Some Code
RaiseEvent Event1(someargs)
End Sub
End Class

View 1 Replies

Raising .net Events From Another Class?

Aug 15, 2011

can I call shared events contained in one class from another class?

for example:

logonclass.vb : handles login logic and authenticates against database
logonmanager.vb: hold current user reference and some logon and timeout events
Logon.vb: A form with a submit button.

I would like to do something like this but I can't get the compiler to agree with it

If VerifyEntries() Then
Try
privLvl = LoginClass.AttemptLogin(txtUserName.Text, txtPassword.Text)[code].....

If this isn't the proper way to wire things together let me know so I can learn to structure differently. In my planning it seemed like I was raising a lot of extra duplicate events from my logonclass to my loginmanager class. Then the loginmanager had to raise it again for the main form to see the change event. It got me thinking that if I publicly shared the events and could raise them from wherever then it would cut down on the amount of events I needed in code and the amount of them flying around at runtime.

View 2 Replies

Vb6 Handle .net Com Class Events?

Nov 13, 2009

i have the ComClassSearchCustomers class and interface IComClassSearchCustomersat .net which used to create a tlb file. The class raise an event inside new. After that i have a vb6 form Form1 which catch the event , but it never see the event.

[Code]...

View 3 Replies

Stop Application Closing Until Backgroundworker Finished?

Jul 25, 2010

How can I stop my application quitting until a backgroundworker has finished? Its an updater, so basically I want the form to hide until the download is finished, and then exit.I've tried to make a setting to tell the app when it is still downloading, and on form closing check this variable, but it won't work. For some reason it still quits!The update window is in a separate form to the main form, so the user clicks 'Finish', the update form closes and the main form stays open.[code]

View 5 Replies

Generate Dialog Result From A Custom Message Box Class?

Aug 3, 2011

I am developing a custom messagebox class like the following-[code]...

View 1 Replies

Generate Info (wrapper) Class From Stored Procedure

Feb 26, 2010

I am trying to speed up the development phase by using codesmith for generating the business class DAL and info class for the tables of my project. There are about 50 tables with relationships parent child many to many and for retrieving data I have to code several inner joins in stored procedures. I have to combine fields from many tables and this makes working with the info class difficult. Is there anyway to generate info class from stored procedures or to be more exact is there a way to parse the result set of the stored procedure and to generate the info class with properties for every column in that result set.

View 3 Replies

Pass Current Web Credentials From Asp.net Web Application To Windows Client Application

Nov 20, 2011

I'm developing a web application that requires the user to log in using forms authentication. inside the webpage you need to download a desktop application that requires to login to the same system too. Is there a way to transfer the current logged credentials from the web application to the windows desktop application without need to login again?. Both applications shares a Login object from an vb.net interface.I tried to save the IP address in the Database but that don't work for me because the website needs to be accessed inside and/or outside of the company and the user cannot login twice in different machines.

View 2 Replies

Cancel Backgroundworker - Got The Error Message" This BackgroundWorker Is Currently Busy And Cannot Run Multiple Tasks Concurrently?

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







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