473,395 Members | 1,556 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,395 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 1343
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.