Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

Problem with events

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
danger - 25 Feb 2008 15:33 GMT
I everybody, first of all sorry for my poor english. I have a problem
with an event that is generated more times very quickly so the
function subscribed doesn't finish his work. What can i do in order to
complete the work of the function before a new event is generated?
I have choosen two options:

1) Put the body of function inside a lock statement (i think is a
really bad idea)
2) Put every data generated with the event inside a list and a
separated thread manage the various operations of the data of that
list.

Does someone have better solutions?

Thanks you
Federico
Jon Skeet [C# MVP] - 25 Feb 2008 15:37 GMT
> I everybody, first of all sorry for my poor english. I have a problem
> with an event that is generated more times very quickly so the
[quoted text clipped - 9 lines]
>
> Does someone have better solutions?

You'll need to give us more information. What's firing these events?
Is it coming in from different threads?

Option 2 sounds like a classic producer/consumer queue - you generate
work in one thread (or potentially many) and another thread (or again,
potentially many if there are no side-effects and dependencies) goes
through and processes that work. That's certainly a very valid
approach in many cases.

Jon
Oddball - 25 Feb 2008 17:16 GMT
> > I everybody, first of all sorry for my poor english. I have a problem
> > with an event that is generated more times very quickly so the
[quoted text clipped - 20 lines]
>
> Jon

Jon is, unsuprisingly enough having had a look through these forums,
on the ball.  Unless the rapid firing is caused by the uncompleted
event handler (some sort of timer going on, which will build into a
crescendo if you stack multiple jobs causing eChina Syndrome) all you
really need to do is queue up the work jobs and handle them sensibly
and timelily... umm... in good time.

Try looking at the MS CCR (http://msdn2.microsoft.com/en-gb/robotics/
default.aspx) if you want a fancy pants solution to this problem.
Threads made easy (for a given subset of thread tasks, massive joins
not included, please read the small print).  Don't be put off by the
fact that it says 'Robotics' all over it - that's just the weird
implementation MS have chosen for this awsome extension.
Jon Skeet [C# MVP] - 25 Feb 2008 18:23 GMT
<snip>

> Try looking at the MS CCR (http://msdn2.microsoft.com/en-gb/robotics/
> default.aspx) if you want a fancy pants solution to this problem.
> Threads made easy (for a given subset of thread tasks, massive joins
> not included, please read the small print).  Don't be put off by the
> fact that it says 'Robotics' all over it - that's just the weird
> implementation MS have chosen for this awsome extension.

Another option is to try the CTP of "Parallel Extensions" which is more
likely to become mainstream than the CCR (not to in any way denigrate
the CCR, of course):

http://www.microsoft.com/downloads/details.aspx?FamilyID=e848dc1d-5be3-
4941-8705-024bc7f180ba&displaylang=en

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet   Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk

luukas9 - 25 Feb 2008 16:10 GMT
> I everybody, first of all sorry for my poor english. I have a problem
> with an event that is generated more times very quickly so the
[quoted text clipped - 12 lines]
> Thanks you
> Federico

Puedes explicarlo también en castellano? Así te puedo echar un cable

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.