473,320 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Event monitoring in a running application

Hi,

this seems like something so basic that there must be some way to do it...Is there a way for Visual Studio or some other tool to let me see Events as they are raised in an application?

For example, I've created a form with two fields. I would like to be able to see ALL the events for the application as I run/debug it. I want to know that clicking on field1 and then field2 produces: fld1.enter, fld1.leave, fld2.enter, etc.

I guess I should stipulate that I don't want to have to place breakpoints or debug writelines in the code. I don't want to have to anticipate which event handlers will be called. I want to see if events I didn't even expect are being raised.
Jul 21 '05 #1
4 1341
Hi,

lets say you have

public class MyForm : Form
{...}

Then you can use reflection over MyForm class, extract the list of all
events and subscribe a common method to everyone of them. And in this
method do whatever you want: Debug.Write, log in file, whatever.

All event handlers have the form MyHandler(object sender, EventArgs e),

so your handler can be:

void MyHandler(....)
{
Control control = sender as Control;
if (control != null)
{
//now here you can use control.Name to get who is the sender
//and use StackTrace to get the caller method, it should be
//something like OnXxxxx, so you will know what event was raised

}
}

And ... if you want all events for underlying controls, you have
complicate the things, and to iterate thru Controls collection of every
control, to get the events for every control and to subscribe them to
your handler as well.

But ... I doubt if you need such a thing. If you need to track down in
what sequence are raised the events to which you already has attached
handlers, you can use the Control.Events property to get all event
handlers already attached. And for every delegate in that list, you can
use Delegate.Combine to add your own tracking handler.

Sunny
In article <00**********************************@microsoft.co m>,
ar*******@topco.com says...
Hi,

this seems like something so basic that there must be some way to do it...Is there a way for Visual Studio or some other tool to let me see Events as they are raised in an application?

For example, I've created a form with two fields. I would like to be able to see ALL the events for the application as I run/debug it. I want to know that clicking on field1 and then field2 produces: fld1.enter, fld1.leave, fld2.enter, etc.

I guess I should stipulate that I don't want to have to place breakpoints or debug writelines in the code. I don't want to have to anticipate which event handlers will be called. I want to see if events I didn't even expect are being raised.

Jul 21 '05 #2
Hi Ron,

I think there are many tools that can hook messages of a window, like
Spy++. Also there are some open source tools available. Control Inspector
is one of them, which deals with .NET managed applications. You can find
the tool with source code from the following link. HTH.

http://www.codeproject.com/csharp/controlinspector.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #3
Hi Ron,

I think there are many tools that can hook messages of a window, like
Spy++. Also there are some open source tools available. Control Inspector
is one of them, which deals with .NET managed applications. You can find
the tool with source code from the following link. HTH.

http://www.codeproject.com/csharp/controlinspector.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #4
Hi Ron,

I'm not quite sure user defined events can be handled as we can only hook
messages from system. User defined events will not send messages.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Randal | last post by:
Does anyone have a code sample of how one would "listen" to a TCP/IP session between an application on the local machine and a remote host. I'm looking for code that would allow me to specify a...
4
by: johnm | last post by:
Hello, We currently are running a CRM application that uses DB/2 7.2 for the data repository. We will be upgrading to 8.2 later this year....maybe....time and resources permitting. The...
9
by: Tim D | last post by:
Hi, I originally posted this as a reply to a rather old thread in dotnet.framework.general and didn't get any response. I thought it might be more relevant here; anyone got any ideas? My...
12
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. ...
4
by: Nick | last post by:
Hi there, I'm running a process object within a .NET app, very simple, the process is declared with events, i'm handling the Exit event and running a win32 application. No matter how the...
3
by: Ron Gliane | last post by:
Hi, this seems like something so basic that there must be some way to do it...Is there a way for Visual Studio or some other tool to let me see Events as they are raised in an application? For...
1
by: brad.serbus | last post by:
I am trying to figure out a way to have health monitoring throw different Event IDs into the event log, and am having a hard time. None of the customization that I have looked through so far has...
2
by: Jack | last post by:
Sorry for the double post (also in the IIS group). We've got an ASP.Net 2.0 app running on IIS6. We kept losing sessions, and enabled health monitoring to see what was happening. This morning...
1
by: Lila Godel | last post by:
My VB.NET 2008 application is setup with a Sub Main and no forms. At run time a NotifyIcon is created with one context menu choice (Close which terminates app). I have no trouble running the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.