Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 11th, 2007, 01:01 PM
Registered User
 
Join Date: Feb 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Event Firing

Hello,

I hope one of you have found a solution to the following problem before. . . Thanks in advance if you have.

I'm receiving events from an external dll (an RTDServer - set up like an observer pattern), and i've a Notify method that's called when there's an update to be collected. I can then collect a System.Array with a list of updates on a separate thread.

The problem is that the list will contain a number of different update types, and i've to set different variables in an object based on the differentupdates andI've to handle that list (one by one). Which of the following are possible/advisable, and can anyone recommend a better approach?

(a) use a hashtable/sortedlist/sorteddictionary with an indexer and the names of some variables in an object. Search the list, set the object variable, and let the object call any other events needed in the get/set method.

(b) write some kind of custom enumerator for the event types or variables to be set.

(c) use a hashtable/sortedlist/sorteddictionary with an indexer an objects of type Event. Just search the list for the indexer, and call the event to subscribers.

(d) some combination of the above.

The only thing is that speed is very important, because I migt have to call these events sequentially - I haven't investigated doing a foreach on the invocation list and calling asynchronously.Although they're small, I'll have possibly a hundred of these objects, with a hundred threads collecting updates.

Any help with this problem would be much appreciated.

Thanks,

Tom.




 
Old June 12th, 2007, 08:19 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Tom,

I'm having trouble visualizing your scenario, can you post some relevant code snippits that show some examples of the update information and classes to change based on the updates?

What about implementing interfaces on the update classes and the classes to be touched by the updates such that a single set of logic can bridge between the disparate classes? Then your arrays of updates can be strongly typed to the interface instead of ambiguously to 'System.Object'.

Thinking back on my suggestion I wonder if the fundamental problem with that solution is that the classes (update information and ones to be touched) are so different that you need to analyze the update type in order to really know what to do? If that is the case, what about expanding the observer to provide more discrete update methods to increase type specificity.

-Peter





Similar Threads
Thread Thread Starter Forum Replies Last Post
selectedindexchanged event not firing kaliaparijat ASP.NET 2.0 Professional 1 June 5th, 2008 08:58 AM
Custom event not firing flegel ASP.NET 2.0 Professional 0 February 23rd, 2007 06:31 AM
onSelectedIndexChanged event not firing??? MTLedari ASP.NET 2.0 Basics 5 December 19th, 2006 10:35 AM
OnSelectedIndexChanged event not firing ethertt77 ASP.NET 2.0 Basics 2 February 20th, 2006 07:34 PM
Session_Start event not firing.. (not Sharepoint) Koroshiya ASP.NET 1.0 and 1.1 Professional 10 February 25th, 2005 05:35 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.