![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | EventPublication and EventSubscription not working. I'm having trouble getting EventPublication and EventSubscription to work. Things compile but the event goes nowhere. Here's the essentials of the sample application which is simply sending a string to be passed to the Debug.WriteLine function. I've typed this in from memory so there could be a typo or two in there but the basic logic should be correct. The original program was created using the new project -> WPF window application wizard. using System.Diagnostics; using Microsoft.Practices.CompositUI.EventBroker; using Microsoft.Practices.CompositUI.Utility; namespace LoggingExperiment { public class Logger { [EventSubscription( "TopicTrace", ThreadOption.Publisher )] public void DoTrace( object sender, DataEventArgs<string> e) { Debug.WriteLine( e.Data ); } } } using System; using Microsoft.Practices.EnterpriseLibrary.Logging; using Microsoft.Practices.CompositeUI.EventBroker; using Microsoft.Practices.CompositeUI.Utility; namespace LoggingExperiemnt { public partial class Window1 : System.Windows.Window { [EventPublication("TopicTrace", PublicationScope.Global)] public event EventHandler<DataEventArgs<string>> DoTrace; public WIndow1() { CallTrace(this, "Calling InitializeComponent"); InitializeComponent(); } public void CallTrace( object sender, string msg ) { if (DoTrace != null) { DoTrace( sender, new DataEventArgs<string>( msg ) ); } } } The code compiles and runs but DoTrace is always null, indicating that the system never decided that it was necessary to establish the publish/subscriber relationship. What am I missing? -- Richard Lewis Haggard General: www.Haggard-And-Associates.com Please come visit here for a couple thousand good giggles!: www.haggard-and-associates.com/Humor/humor.htm |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| windows vista restore not working/blue screen help/safe mode not working | Vista General | |||
| MS Intellipoint stopped working but ctrl panel says working proper | Vista hardware & devices | |||
| Re: Vista Internet not working, Ping by DNS is working | Vista networking & sharing | |||
| Re: Right click stops working/New tabs stop working/Menu bar disappear | Vista performance & maintenance | |||
| Creative Audigy 2 drivers working on Vista Working | Vista hardware & devices | |||