Click here to Skip to main content
15,923,087 members
Home / Discussions / Article Writing
   

Article Writing

 
GeneralRe: Add Event handlers Issue at Page Load Pin
Pete O'Hanlon4-Aug-08 2:49
mvePete O'Hanlon4-Aug-08 2:49 
GeneralRe: Add Event handlers Issue at Page Load Pin
Vasudevan Deepak Kumar28-Aug-08 8:08
Vasudevan Deepak Kumar28-Aug-08 8:08 
AnswerRe: Add Event handlers Issue at Page Load Pin
Paul Conrad4-Aug-08 10:39
professionalPaul Conrad4-Aug-08 10:39 
QuestionArticle on MOSS Pin
balaji.t1-Aug-08 1:33
balaji.t1-Aug-08 1:33 
AnswerRe: Article on MOSS Pin
Paul Conrad1-Aug-08 5:44
professionalPaul Conrad1-Aug-08 5:44 
AnswerRe: Article on MOSS Pin
Vasudevan Deepak Kumar28-Aug-08 8:08
Vasudevan Deepak Kumar28-Aug-08 8:08 
GeneralRe: Article on MOSS Pin
Pete O'Hanlon28-Aug-08 8:16
mvePete O'Hanlon28-Aug-08 8:16 
QuestionIs my DelegLink class brilliant, useful, stupid, or horrible (worth a write-up?) Pin
supercat925-Jul-08 14:13
supercat925-Jul-08 14:13 
I've just created a new thread-safe generic pseudo-Event class called DelegLink. I'd be happy to write it up if it's worthwhile; if it's silly then I won't bother. I'm not totally keen on the identifier names I've chosen; let me know if some other names would be better.

Anyway, is this thing brilliant, useful, silly, or horrible?

A DelegLink object holds a thread-safe collection of objects wishing to receive pseudo-events. Objects may subscribe at any time; simultaneous subscriptions will always succeed. Each object in the DelegLink holds an optional Tag (a plain Object).

Class DelegLink
  Function Subscribe(Subscriber As Object, Tag As Object) As DelegLink
  ' Subscribes an object.  Returns a DelegLink that may be used to unsubscribe

  Sub Unsubscribe()
  ' Invoking Unsubscribe on a deleglink returned by an earlier call to Subscribe
  ' will cancel the subscription.

  Sub Exec(Of T)(Param as T)
  ' Invokes DelegLink.iAct.Act(of T)(Param, Tag, SendLink) on all subscribers
  ' that implement it.  Subscribers whose Act() returns True will be unsubscribed.

  Interface iAct(of T)
    Function Act(Param as T, Tag as Object, SendLink as DelegLink) As Boolean
  End Interface

  Readonly Property Base As DelegLink
End Class

A DelegLink holds weak references to its subscribers; subscribers that are garbage-collected will be unsubscribed without incident. Strong references are held to Tag, but those references will go away after an object is unsubscribed.

Because it is necessary to type-check each object to see if it supports iAct(of T) and type-cast the ones that do, I would expect that DelegLink to be slower than the Event facility in .net. On the other hand, it does offer some advantages including thread safety and object tags.
AnswerRe: Is my DelegLink class brilliant, useful, stupid, or horrible (worth a write-up?) Pin
Paul Conrad26-Jul-08 17:41
professionalPaul Conrad26-Jul-08 17:41 
AnswerRe: Is my DelegLink class brilliant, useful, stupid, or horrible (worth a write-up?) Pin
Scott Dorman26-Jul-08 17:55
professionalScott Dorman26-Jul-08 17:55 
QuestionArticle with little or no code? Pin
mhenderson44215-Jul-08 2:04
mhenderson44215-Jul-08 2:04 
AnswerRe: Article with little or no code? Pin
Scott Dorman15-Jul-08 2:41
professionalScott Dorman15-Jul-08 2:41 
GeneralRe: Article with little or no code? Pin
mhenderson44215-Jul-08 2:58
mhenderson44215-Jul-08 2:58 
GeneralRe: Article with little or no code? Pin
Scott Dorman15-Jul-08 3:09
professionalScott Dorman15-Jul-08 3:09 
GeneralRe: Article with little or no code? Pin
mhenderson44215-Jul-08 3:26
mhenderson44215-Jul-08 3:26 
QuestionPdfLibrary Pin
bounci13-Jul-08 11:09
bounci13-Jul-08 11:09 
AnswerRe: PdfLibrary Pin
Luc Pattyn13-Jul-08 12:17
sitebuilderLuc Pattyn13-Jul-08 12:17 
AnswerRe: PdfLibrary Pin
Paul Conrad17-Jul-08 16:33
professionalPaul Conrad17-Jul-08 16:33 
QuestionHow would i make my own Remote desktop client Pin
mike warren12-Jul-08 23:02
mike warren12-Jul-08 23:02 
AnswerRe: How would i make my own Remote desktop client Pin
Scott Dorman13-Jul-08 2:38
professionalScott Dorman13-Jul-08 2:38 
QuestionMultithreaded thumbanil maker request Pin
mhn2176-Jul-08 21:30
mhn2176-Jul-08 21:30 
AnswerRe: Multithreaded thumbanil maker request Pin
Scott Dorman13-Jul-08 2:41
professionalScott Dorman13-Jul-08 2:41 
GeneralRe: Multithreaded thumbanil maker request Pin
mhn21713-Jul-08 17:08
mhn21713-Jul-08 17:08 
QuestionResearching Opinions: Professional System Library Pin
Vitaly Tomilov3-Jul-08 22:59
Vitaly Tomilov3-Jul-08 22:59 
AnswerRe: Researching Opinions: Professional System Library Pin
Vitaly Tomilov5-Jul-08 5:36
Vitaly Tomilov5-Jul-08 5:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.