Solved

C# - How to implement event listener from this thirdparty COM

Posted on 2014-10-01
3
190 Views
Last Modified: 2014-10-21
Hi,

I am using a thirdparty DLL to initiate a download.

I'm told to use the following code snippet to be notified when the download is complete.

(svxFile.saver as _IStreamCollectorEvents_Event).stopped += (collector) => 
{ 
//do something
 };

Open in new window


How do I use this in a C# Console Application?  Where should it go? I cant the event to fire no matter where I put it.

Thank you

static class Program
    {
        static SVXFile file_ = new SVXFile();        

        static void Main(string[] args)
        {            
            (file_.saver as _IStreamCollectorEvents_Event).stopped += (collector) => { Console.WriteLine("Download Result: " + collector.ToString()); };
            (file_.saver as _IStreamCollectorEvents_Event).failed += (sender,error) => { Console.WriteLine("Download Result: " + error.message); };
            
            //Download code removed
            
            Console.WriteLine("Done");
            Console.Read();
        }        
    }

Open in new window

0
Comment
Question by:mhdi
  • 2
3 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40356207
Anywhere before you actually use the component, I suspect. I imagine Main should be fine.
0
 

Author Comment

by:mhdi
ID: 40356216
Hmm. Thats where I have it and I still can't get it to fire. What's the best way to debug these kinds of events?
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 40356258
There nothing overly special about events. They are just special implementations of the Observer Pattern created as a language feature of .NET. You should be able to debug them like any other method. Are you certain your external component is raising the event? Is there some flag you have to set?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now