PC Review


Reply
Thread Tools Rate Thread

COM Connection points and C# delegates

 
 
lallous
Guest
Posts: n/a
 
      30th Aug 2006
Hello

I am not very experienced with this issue and would your opinion on
whether it is healthy or not:


1) I created an ATL COM object (say MyCOM):
- that supports connection points
- that exposes couple of methods such as:
BeginOperation()
GetInformation()
- Exposed some events in the _IMyCOMEvents interface which was created
automatically by the wizard, such as:
OnNewItem()
OnProgressItem()
OnEndItem()


2) Implemented the connection points, etc...


Some information about BeginOperation():


1) It takes some initial parameters and stores them in the class member
variables
2) It creates a thread (CreateThread API), passing "this" as context
3) returns to the caller


The thread proc of BeginOperation():
1) do some lenghty operations (like file copying)
2) while doing the operations, fire the events when needed:
Fire_OnItemProgress() ....


I wanted to test this COM from C#, so:


1)Added reference to the COM
2)created a new instance of the object in the form' s constructor
3)Added new delegates to the object's OnNew, OnEnd, ...
The delegates updates the screen such as:
void OnNewItem(int itemNo)
{
StatusLabel.Text = "Currently processing item #" + itemNo.ToString();



}


etc...

Now, I am facing some weird issues:
1)sometimes, events are called, but only one line is being executed,
and then directly another event is being fired, w/o the first one
finishing
2)if application is ran w/ the debugger, it looks like the screen is
not updated as if some events are not triggered.


Please advise if this is the correct way of doing this.


Regards,
Elias


 
Reply With Quote
 
 
 
 
Willy Denoyette [MVP]
Guest
Posts: n/a
 
      30th Aug 2006
Note that doing so, you will have to marshal the update of the UI to the UI
thread, your event handlers do run on an auxiliary thread (the one created
in your component), so you may not access the UI elements directly. Check
the docs on Control.BeginInvoke and Invoke.

Willy.

"lallous" <(E-Mail Removed)> wrote in message
news:uSnpV8$(E-Mail Removed)...
| Hello
|
| I am not very experienced with this issue and would your opinion on
| whether it is healthy or not:
|
|
| 1) I created an ATL COM object (say MyCOM):
| - that supports connection points
| - that exposes couple of methods such as:
| BeginOperation()
| GetInformation()
| - Exposed some events in the _IMyCOMEvents interface which was created
| automatically by the wizard, such as:
| OnNewItem()
| OnProgressItem()
| OnEndItem()
|
|
| 2) Implemented the connection points, etc...
|
|
| Some information about BeginOperation():
|
|
| 1) It takes some initial parameters and stores them in the class member
| variables
| 2) It creates a thread (CreateThread API), passing "this" as context
| 3) returns to the caller
|
|
| The thread proc of BeginOperation():
| 1) do some lenghty operations (like file copying)
| 2) while doing the operations, fire the events when needed:
| Fire_OnItemProgress() ....
|
|
| I wanted to test this COM from C#, so:
|
|
| 1)Added reference to the COM
| 2)created a new instance of the object in the form' s constructor
| 3)Added new delegates to the object's OnNew, OnEnd, ...
| The delegates updates the screen such as:
| void OnNewItem(int itemNo)
| {
| StatusLabel.Text = "Currently processing item #" + itemNo.ToString();
|
|
|
| }
|
|
| etc...
|
| Now, I am facing some weird issues:
| 1)sometimes, events are called, but only one line is being executed,
| and then directly another event is being fired, w/o the first one
| finishing
| 2)if application is ran w/ the debugger, it looks like the screen is
| not updated as if some events are not triggered.
|
|
| Please advise if this is the correct way of doing this.
|
|
| Regards,
| Elias
|
|


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Connection Lines Between Data Points CLR Microsoft Excel Charting 2 22nd Jan 2010 07:43 PM
Connection points on relationship diagram MikeB Microsoft Access 3 13th Feb 2008 06:32 AM
Flow Chart Connection Points =?Utf-8?B?UmFjaGVs?= Microsoft Word Document Management 1 14th Feb 2005 02:13 PM
connection points =?Utf-8?B?bWF0dHZtaWxscw==?= Microsoft Powerpoint 2 26th Oct 2004 05:21 PM
Connection Points wondering Microsoft Powerpoint 1 23rd Jun 2004 08:58 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:21 PM.