架构师_程序员_码农网

Retrieve password
Register

QQ登录

Just one step to get started

Search
Views:34112|Replies: 4
打印 上一主题 下一主题

[ NET/C# BlockingCollection based Background Task Queue

[Copy link] .
跳转到指定楼层
owner
发表于 2021-1-23 11:53:25| 看该作者回帖奖励|ReverseBrowse|Read Mode
c# wraps a universal QueueHelper queue
h ttps:// www.itsvse.com/thread-5029-1-1.html
NET/C# BlockingCollection based implementation of simple logging
h ttps:// www.itsvse.com/thread-9512-1-1.html
Scenario: in the execution of certain operations, do not need to return any message, can be handled in the background of the function, can be put into the background of any inside the implementation. For example: sending mail, writing logs and so on.

Previously written based on ConcurrentQueue and Thread task queue, this paper uses BlockingCollection can be better achieved.

QueueBlockingCollection code is as follows:

For example, let's implement a background task to send emails and inherit the QueueBlockingCollection abstract class as follows:

The call method is as follows:


The simple console backend outputs a string with the following code:

The rendering is as follows:



(End)




Previous: ASP.NET Core receiving POST JSON parameters can not be serialized into an object
Next Article: .net/c# make cpu processor utilization 100%

Related posts

The first time I've seen a tutorial on how to do this, I've seen it on a lot of other blogs.
nhl jerseys for sale
sofa
owner|Posted on 2021-6-11 15:05:55|Only see this author
There is something wrong with the code, the latest code is as follows:


Code farmer network, only published in the process of practice, encountered technical difficulties, do not mislead others.
biny2023
发表于 2023-4-10 17:35:55| 看该作者
I'm going to take a look at it.
The code farmer network, only published in the process of practice, encountered technical difficulties, do not mislead others.
nike air max 90 pas cher, nike air max 90 pas cher
flooring
发表于 2023-5-8 09:58:53| 看该作者
Consumers can also get the message with the following code:

Code Farmer, only published in the process of practice, encountered technical difficulties, do not mislead others.
ugg boots sale
5#
owner|Posted on 2023-5-8 22:13:24|Only see this author
NET Core High-Performance Queues Channels Usage
h ttps:// www.itsvse.com/thread-10584-1-1.html
NET Core high-performance queuing Channels use
You need to log in before you can post back Log in | Register

This version of the integral rules

DISCLAIMER:
All software, programming materials or articles released by the code farmer network is limited to study and research purposes; the above content shall not be used for commercial or illegal purposes, otherwise, all the consequences please be the user's own responsibility. This site information from the network, copyright dispute has nothing to do with this site. You must completely remove the above content from your computer within 24 hours of downloading. If you like the program, please support the genuine software, buy registration and get better genuine service. If there is any infringement, please contact us by email to deal with it.

Mail To:help@itsvse.com

QQ| ( ICP备14021824号-2 )|Sitemap

GMT+8, 2024-9-19 00:25

Quick ReplyBack to topBack to list