C # implement a simple work queue Scheduler

Source: Internet
Author: User

In some cases, a scheduler is needed to handle some work, such as network processing.ProgramWhen the received data is stored in the queue, the next receiving operation can be processed as quickly as possible. the received data information is processed by the debugger, such as data analysis and data packet processing. since the scheduler is responsible for processing the work, it is best to set a rule for the work to be processed, so as to facilitate the flexible expansion of processing in the future.

Rule setting Interface

?
12345 Public interface iworkitem: idisposable { void execute (); }

In fact, the interface is very simple as an execute method, indicating to execute the job; so why do we need to implement idisposable? The purpose is to provide a release operation description for this job, when this task is completed, there will be a release action to deal with related matters.

Scheduler implementation

?
123456789101112131415161718192021222324252627282930313233343536373839
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.