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


ADVERTISEMENT

Gui :: Logging Options With BackgroundWorker?

Feb 26, 2012

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:

View 6 Replies

Logging From A Class?

May 23, 2012

I have a class for serial communications (call it CSerial), based on a property value (CSerial.LogLevel), I'd like to produce various levels of logging information about data sent and received to the serial port.Given that it's a reusable class, there's no way of telling whether the log data should be sent to the console, a text box, a file, etc. This would be determined by the application using the class, so I can't write all of the different output options into a method in the class.Question:What's the best way to implement this? I have some ideas:1. Create a Log method and then "override" it in my main application to handle the most suitable form of output? Can I "override" a method as part of an instance? Or do I need to create a new class that inherits my original one, override the method there and then create an instance of my new class?

View 3 Replies

.net - Logging From Msbuild Custom Task Using Console Class?

Feb 28, 2011

I'm trying to convert an existing command line tool into msbuild custom task.This tool logs messages and errors using the System.Console class.I've added to the tool's assembly a class that inherits from Microsoft.Build.Utilities.Task and calls the tool main function, and the custom tool works fine - but no messages/errors are displayed (on the Visual Studio output window).I would like to avoid changing the original tool's code (otherwise I could change every "Console.Error.WriteLine" to "Log.LogError").I thought of changing the stdout and stderr streams of console by calling Console.SetOut and SetError before calling the tool's main function. For that, I would need to implement a class that inherits from TextWriter.

[Code]...

View 2 Replies

VS 2010 Make Class Properties With Multiple Options?

May 20, 2011

I am just learning about making classes and need to make one with 2 properties.Below is the beginning of a class for ingredients in a coffee machine.But I want sugar and water to also hold name (string) ='sugar' and number(integer) = 4 so its like thisIngredients.coffee.name or ingredients.coffee.number[code]

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

Visual Studio Logging In/ Logging Out?

Feb 17, 2012

Using visual studio (Winforms) with sql server (R2). If you can login by inserting the correct values in the textfields (vb.net) that is connected in the database . How do i code the log out?

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

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

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

VS 2010 Options View Control - Child Options?

Aug 20, 2011

I am in need of a form that shows various options, exactly like the Options in Visual Studio. Since there are so many options I too want them categorized, with a TreeView to the left taking care of showing the right category.The usual 'easy' approach here would be to just place a TreeView control on the form, add some nodes, and give those nodes a tag or key that corresponds to a panel or UserControl with the options for that category.Since there will be a lot of options however, this is not really feasible design-wise; the form would be cluttered with possibly 50 panels, all of which I would need to select and bring to front from time to time to add controls to them that represent the options.

So I decided to create a custom control that does exactly that. The control is very similar to my Wizard usercontrol, users can add OptionsPanels at design time, which inherit Panel and simply represent one panel of options. When they do, the panel is added to a container panel, and at the same time a TreeNode is added to a TreeView. The control uses a custom ControlDesigner to handle design-time clicks in the Treeview, selecting a different node would select and bring to front the corresponding panel, allowing the user to add the controls he wants.

Due to the design time support the problem of having 50 panels is no longer present, only one panel will be visible at a time and selecting the right panel is as simple as selecting the corresponding TreeNode, just as during run-time. Anyway, I got all this working, but only for a single 'level' of categories. As you can see in the Visual Studio options, there can be multiple levels of categories. For example, the Environment node has a bunch of children, where each child represents one 'options panel'. There can even be deeper nesting, see the Text Editor node for example.Let me begin by drawing out the basics of how my control works so far.

The main control is an OptionsView control, which contains a SplitContainer with a TreeView to the left and a OptionsPanelContainer to the right. The OptionsPanelContainer is merely a Panel to which only OptionsPanel controls can be added, and which raises events when this happens, as well as when OptionsPanels are removed from it. An OptionsPanel also inherits Panel, and these are the actual panels the users will see in the control, one for each option category.For now, each OptionsPanel has exactly one corresponding TreeNode (and vice versa). In the Visual Studio options, each 'parent' category usually has a 'General' node as the first child, and the parent and this General node show the same option panel, but I am ignoring that for the moment.

The OptionsView control has a property Panels that returns the ControlCollection (Controls property) of the OptionsPanelContainer (in other words: it returns a collection of OptionsPanels that are in this container panel).

vb.net
<Editor(GetType(Designers.OptionsPanelCollectionEditor), GetType(UITypeEditor))> _ <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)> _ Public ReadOnly Property Panels As Control.ControlCollection Get Return Me.PanelContainer.Controls End Get End Property

A custom CollectionEditor for this property takes care of the designer: even though the property type is ControlCollection, the CollectionEditor knows it should create instances of the OptionsPanel control instead of just Controls.When it does this, a corresponding TreeNode is also created and its Tag property is set to the OptionsPanel. Vice versa, the Node property of the OptionsPanel is set to the node. Hence the node and panel both know their corresponding object.

vb.net
Public Class OptionsPanelCollectionEditor Inherits System.ComponentModel.Design.CollectionEditor Public Sub New(type As Type) MyBase.New(type) End Sub Protected Overrides Function CreateCollectionItemType() As System.Type

[code]....

So far so good, this all works fine. I can add Panels via the designer and when I do a new TreeNode appears in the TreeView. I can select this node and the panel becomes visible (comes to the front).Now, I am a little stuck. How do I implement child option panels? And more importantly: how do I let the user add child panels?The most logical choice I think is to let each OptionsPanel have a property (ChildPanels or something) that returns the child OptionsPanels for that panel. Once the user selects an OptionsPanel then, he can look in the property grid to find its ChildPanels property and add child panels to that.

There is a problem though: what would this property return? It must return a ControlCollection of some container (this is, I think, a requirement for the designer features to work, otherwise panels are not added to the Form.Designer.vb file). But there is no container. I cannot add them to the OptionsPanel itself, that would make no sense because the parent OptionsPanel has its own set of controls (the options itself...), there cannot be another (fully docked) Panel on top of those obviously.The container of the main OptionsView then? That is not an option either, its Controls collection holds ALL OptionsPanels, not just the children of the selected panel. I cannot 'select' only the right panels either, that would require me to return a new instance of ControlCollection, it would be impossible to return the actual ControlsCollection that holds merely a small selection of its controls.

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

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

Or Keyword - Does Options = Options Or Does It Set RegexOptions.none

Feb 28, 2010

With the following piece of code

CODE:

The Or keyword is confusing me. So in the above example which variable gets set. Does options = options or does it set RegexOptions.none.

View 9 Replies

BackgroundWorker Thread Communicate With The Primary UI Thread When Encapsulated In A Class?

Jul 1, 2010

A BackgroundWorker thread can pass data to the primary thread. It does it via the RunWorkerCompleted and ProgressChanged events, which I believe run in the primary thread. I would like to encapsulate the BackgroundWorker control in a class so that I can instantiate it more than once. But I don't know how the BGW can then communicate with the primary thread. If the BGW control is within a class, it does not have access to the properties outside the class. In that case, how can the BGW pass data to the thread that instantiated it?

[Code]....

View 3 Replies

Hypothetical Controls - Options Checked As Enabled In FrmConfig Effects - Controls (like Buttons/menu Options) Are Enabled In FrmMain

Nov 26, 2010

As i'm learning more and more about developing ive just got my head around creating classes and modules, i started wondering about something to do with configuration of applications where deployment is in a more diverse environment say in a company where different branches dont need access to all parts of a program, so i thought id throw the question out there in a basic sense and get some feedback. so i can go off and do some more reading and learning.

So the scenario in my head is like this.

So we have for arguments sake FrmConfig which is the master configuration form, then we have FrmMain which is the root menu our application general user interfaces with. So here based on what options are checked as enabled in FrmConfig effects what controls (like buttons/menu options) are enabled in FrmMain.

View 2 Replies

Backgroundworker Inside Another Backgroundworker?

Apr 2, 2012

i'm in the need to start a backgroundworker inside another one.Now...The first one BGW starts a for cycle, and inside this one there is the second BGW that has to upload an image to a server.The trouble is that, the progress event and the complete event of the internal BGW are never called.

View 11 Replies

.net - Logging Off On ASP.NET 3.5 Website?

Jul 19, 2010

I'm getting desperate here trying to find the problem, and I don't know where to start looking for it.

Here are the symptoms:I've noticed, that when a user logs on in the morning, he is then immediately logged off, then when he logs on again, everything is fine and he can work on the site.

Every once in a while, when the user clicks a link, the page takes a lot of time to load, but it never actually loads, and the user is thrown to the login page.Also, after an Exception has occurred in the website, the user is then thrown to the login page. It's as if the exception clears somehow the session.

[Code]...

View 5 Replies

ASP.net Web Server Not Logging On

Apr 20, 2012

I have inherited a ASP.net site, and I've made some changes too to some of the VB code and CSS, and have hosted it on a FTP. It uses an SQL DB to allow users to log in and calls stored procedures.The site complies with no errors, and allows me to log in as a user, and can works perfectly on testing.However, once uploaded to the FTP, it no longer allows me to log in as a user. It hangs for a while, and then returns a message saying that the password is wrong, despite it being correct. It doesn't throw an error message, and I think I've narrowed it down to something to do with the Web.config file, but I'm at a loss as how it's not working, especially with the lack of error messages being thrown.[code]

View 2 Replies

C# - Is Passive Logging Possible In .NET

Mar 26, 2009

I was wondering is there a way anyone knows of to "inject" a logger into an application such that it passively monitors the thread and quietly logs processes as they occur without having to do things like: [Code] It would then monitor everything that goes on inside of that method including passed in arguments along with method calls and values passed into those methods, exceptions that occur etc. Has anyone implemented something like this in the past? Could it even be implemented? Is logging in this fashion just a pipe dream?

View 6 Replies

Logging In 0 Httpwebrequest

Mar 22, 2011

can any one see any thing wrong with my code. I swear it did work once or twice. * code now removed as updated below

View 2 Replies

Logging Into A Website

Jan 8, 2009

Im trying to login to my website with vb.net (without the use of java script).webbrowser.documents.forms(0).submit..All i can find on the internet is to use that there to click the login button but it doesn't work.I also found this for filling in the login forms but im having trouble understanding how it works.[code]So if anyone could explain to me how to fill a form or how to click a submit button.

View 1 Replies

Logging Into A Website Through VB?

Sep 27, 2011

Logging Into A Website Through Vb

View 7 Replies

Logging Onto A Website

Feb 19, 2010

I have a requirement to log on to a web site using a vb.net console application. It's not an FTP site, that would be too easy. It's an email site. I haven't a clue how to do it

View 2 Replies

.net - Creating A Logging Project In VB From Zero?

Dec 27, 2011

I've been assigned to start a new Logging Project from zero in VB.NET.The final exit of the main project is information organized in paragraphs like this:

[code]...

Every paragraph correspond to a database connection. Every connection is made with an entire diferent database.i need my logging project to save everything the user does, so the logging exit would be like the system exit but with exceptions and other important information like this: Paragraph's title 1 Paragraph's content 1.Paragraph's title 2 User wasn't able to see this information because an exception ocurred: System.WhateverException:couldn't connect to WCF.as you can see the exit is the same but i need to create a detail log because the information is delicate and the DBA needs to now wich user did what and what was the response of the system. Also i need it to be and independant project so i can re-use it in another projects. Seeing the final exit of both the main project and the logging project, what would you recommend me to use for logging in .NET?

View 1 Replies

.net - Logging Application Block?

Aug 18, 2010

We have a current implementation of a log file manager where it's two main purposes are to 1. rename files generated by other programs with a date/time stamp so they create new ones, and 2. delete files older then X amount of days from a specified folder. The program also makes it's own log file which records when these events happen.Do you think the Logging Application Block would be useful in this instance? The old file manager is written in VB 6.0 and an upgrade to VB .Net would not take too long, but is it worth it to try and implement LAP into it?

View 1 Replies

Asp.net - Logging In Simultaneously In Two Websites?

Aug 17, 2011

I have two websites "WEBSITE 1" and "WEBSITE 2"...now i want that when someone logs in to "WEBSITE 1" he does not have to log in to "WEBSITE 2" and vice versa...ie when he/she logs in to any one of he websites and opens the other one simultaneously he/she does not have to login to the other one.For eg :- when you are logged in in gmail...you do not have to log in in youtube or orkut or google+

View 1 Replies

Asp.net Active Directory Logging In?

May 24, 2009

i would like to be able to login on a webpage using a valid active directory username and password.user name and password are entered in textboxes. if they are correct then i would like to redirect to another page.how can this be coded.in a second task after some code is performed, log in as an administrator using code and unlock the account.i have heard that this is called impersonation. how can i perform the above?i'm using visual web developer 2008 and vb.net

View 1 Replies

How To Get UserControl Visible After Logging In

Feb 14, 2012

I have a popup login usercontrol in a masterpage, once logged in I want another usercontrol on a content page to appear automatically, currently it only appears if I manually refresh the page.

MasterPage - > login usercontrol
View.aspx - > bookmark usercontrol (should appear after logging in)
login usercontrol in Master Page
<asp:UpdatePanel ID="login" runat="server" UpdateMode="Conditional">
<ContentTemplate>
[Code] .....

After logging in how can the Bookmark usercontrol on View.aspx appear. Do I need to use an updatepanel?

View 1 Replies

Logging IPs That Visit A Site?

Jan 23, 2012

Im currently writing a code that can log ALL of the IP(')s that view a site. I kinda want a code that goes something like

Timer1.tick
textbox1.text = textbox1.text + loggedips.

Or something similar is fine also.After that I want the logs to be saved into a txt file, (I can do this part)Then the user will enter a new site to be logged. Once that is done that will also be saved into a txt file. Etc....Then finally if any IPS that are the same show up in the text files then the user will get that IP in a textbox.

View 11 Replies







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