• (2 Pages)
  • +
  • 1
  • 2

Quick and easy custom events Demonstrated with simple event-triggered logging

#16 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5582
  • View blog
  • Posts: 11,941
  • Joined: 02-June 10

Posted 15 April 2011 - 10:01 AM

This can be somewhat misleading since all of your test application is taking place in the same thread.

The subscriptions happen in order. When an event gets raised notification happens in that same order. The Console takes commands in order.

If you have event subscriptions that take advantage of parrallel processing in different threads and even on different cores of a multi-core PC you would see dramatic time savings in real-world code where each thread is actually performing some real processing and not just outputting to the console which is a bit of a bottleneck.
Was This Post Helpful? 1
  • +
  • -

#17 here.to.code  Icon User is offline

  • D.I.C Head

Reputation: 20
  • View blog
  • Posts: 55
  • Joined: 15-February 11

Posted 15 April 2011 - 12:36 PM

The test is a valid for testing your statement that was pinned against your method vs calling of a function that does the same thing. All I'm validating is that your method is also sequential.
Also this has nothing to do with multi-threading or parallel programming either way. Like I said it was just to test your statement. Which is false.
Was This Post Helpful? 0
  • +
  • -

#18 tlhIn`toq  Icon User is offline

  • Please show what you have already tried when asking a question.
  • member icon

Reputation: 5582
  • View blog
  • Posts: 11,941
  • Joined: 02-June 10

Posted 15 April 2011 - 01:41 PM

When I say 'sequential' I mean that the first item has to finish completely before the second item can begin. That at no time are the two methods happening at the same time (concurrently). You can start two methods in sequence same time, have each require several seconds to complete then finish in a different order. Just because they started A, B, C doesn't mean they will finish A, B, C.

With small, short methods on a single thread targeting into the console (itself a sequential output) you just can't see the difference between direct calling of methods and events activating other components and more involved processes.

If you feel you don't need to use events and that you can accomplish everything you want by just calling the methods directly then please feel free to pursue your style of coding. Coding does indeed require and create a personal style and that is one of the things I love: There is no single, one right way to do something. Ten coders will find ten ways to write the same program and every one of them will have enough distinct stylistic differences to be able to identify the coder. Its like identifying an artist by looking at the style and brushstrokes even if they didn't sign the painting.
Was This Post Helpful? 2
  • +
  • -

#19 Mallaboro  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 55
  • Joined: 26-April 10

Posted 10 August 2012 - 07:50 PM

Thanks again for your help. This guide was just what I was after. :)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2