This chapter mainly discusses atomic operations under multithreaded competition. Knowledge Points Race Conditions Thread Synchronization CPU Time Slices and Context Switching Blocking Kernel Mode and User Mode Interlocked Class 1. Issues 2. Interlocked.Increme…

2020年4月18日 0条评论 110点热度 0人点赞 痴者工良 阅读全文

本章主要讲述多线程竞争下的原子操作。 知识点 竞争条件 线程同步 CPU时间片和上下文切换 阻塞 内核模式和用户模式 Interlocked类 1,出现问题 2,Interlocked.Increment() 3,Interlocked.Exchange() 4,Interlocked.CompareExchange() 5,Interlocked.Add() 6,Interlocked.Read() 知识点 竞争条件 当两个或两个以上的线程访问共享数据,并且尝试同时改变它时,就发生争用的情况。它们所依赖的那部分共…

2020年4月18日 0条评论 3819点热度 0人点赞 痴者工良 阅读全文

1, Lock Lock Prototype Lock Code Example 2, Monitor How to Use Explanation Example Setting Lock Timeout In C#, the lock keyword and Monitor class can be used to address the issues of multi-threaded resource locking and deadlocks. Official Explanation: The lock…

2020年4月17日 1条评论 3375点热度 0人点赞 痴者工良 阅读全文

1,Lock lock 原型 lock 编写实例 2,Monitor 怎么用呢 解释一下 示例 设置获取锁的时效 C# 中,可以使用 lock 关键字和 Monitor 类来解决多线程锁定资源和死锁的问题。 官方解释:lock 语句获取给定对象的互斥 lock,执行语句块,然后释放 lock。 下面我们将来探究 lock 关键字和 Monitor 类的使用。 1,Lock lock 用于读一个引用类型进行加锁,同一时刻内只有一个线程能够访问此对象。lock 是语法糖,是通过 Monitor 来实现的。 Lock 锁…

2020年4月17日 1条评论 3365点热度 0人点赞 痴者工良 阅读全文

public IConfigurationRoot Config { get; } = new ConfigurationBuilder() .SetBasePath(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "Options")) .AddJsonFile("SystemConfig.json", optional: true, reloadOnChange: true)[......…

2020年4月16日 0条评论 112点热度 0人点赞 痴者工良 阅读全文

public IConfigurationRoot Config { get; } = new ConfigurationBuilder() .SetBasePath(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "Options")) .AddJsonFile("SystemConfig.json", optional: true, reloadOnChange: true) .Build(); [......] 继续阅读

2020年4月16日 0条评论 2964点热度 0人点赞 痴者工良 阅读全文

/// <summary> /// base64转为图片存储到本地 /// </summary> /// <param name="base64"></param> /// <param name="imagesPath"></param> /// <returns></returns> public static async Task<string[......]继续阅读

2020年4月16日 0条评论 88点热度 0人点赞 痴者工良 阅读全文

下面是一张图片的 base64 编码 下面代码是很久前写的了,暂时不改,为了速度,请修改字符串操作部分的代码。 /// /// base64转为图片存储到本地 /// /// /// /// public static async Task ImageToFile(string base64,string imagesPath) { if (String.IsNullOrEmpty(base64)) return null;[......]继续阅读

2020年4月16日 0条评论 4169点热度 0人点赞 痴者工良 阅读全文

Solution: Use RandomNumberGenerator to generate random numbers. https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.randomnumbergenerator?view=netcore-3.1 [......] 继续阅读

2020年4月16日 0条评论 88点热度 0人点赞 痴者工良 阅读全文

解决方法: 使用 RandomNumberGenerator 来生成随机数。 https://docs.microsoft.com/zh-cn/dotnet/api/system.security.cryptography.randomnumbergenerator?view=netcore-3.1 [......] 继续阅读

2020年4月16日 0条评论 3535点热度 0人点赞 痴者工良 阅读全文

Table of Contents 1. Get Current Thread Information 2. Manage Thread States 2.1 Starting and Passing Parameters 2.1.1 ParameterizedThreadStart 2.1.2 Using Static Variables or Class Member Variables 2.1.3 Delegates and Lambda 2.2 Pause and Block 2.3 Thread Stat…

2020年4月15日 0条评论 3546点热度 3人点赞 痴者工良 阅读全文

目录 1,获取当前线程信息 2,管理线程状态 2.1 启动与参数传递 2.1.1 ParameterizedThreadStart 2.1.2 使用静态变量或类成员变量 2.1.3 委托与Lambda 2.2 暂停与阻塞 2.3 线程状态 2.4 终止 2.5 线程的不确定性 2.6 线程优先级、前台线程和后台线程 2.7 自旋和休眠 本篇是《多线程入门和实践(初级)》的第一篇,也是大家相当熟悉和不屑的的最简单的入门部分。作为系列文章,笔者将从最简单的部分开始,与各位伙伴一起不断学习和探究 C# 中的多线程。 对于…

2020年4月15日 0条评论 3536点热度 3人点赞 痴者工良 阅读全文

Tip: 111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111. Tip: If the algorithm to be processed is relatively simple, you can write it directly into …

2020年4月12日 0条评论 86点热度 0人点赞 痴者工良 阅读全文

文章内容有知识点提示时: 提示:111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111。 提示:如果需要处理的算法比较简单的话,可以直接写进委托中,不需要另外写方法啦。 提示: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx…

2020年4月12日 0条评论 3012点热度 0人点赞 痴者工良 阅读全文

Reimage Repair is a very powerful tool that can diagnose system issues and repair the system. It can easily fix various errors encountered during Windows 10 updates. Open cmd with administrator privileges and enter SFC/scannow to scan the system. You can use d…

2020年4月4日 0条评论 88点热度 5人点赞 痴者工良 阅读全文

Reimage Repair 是一个非常强大的工具,能够诊断系统问题,修复系统。 对于 windows 10 更新时碰到的各种错误,使用此软件可以很容易地修复系统。 以管理员权限打开cmd,输入 SFC/scannow 也可以扫描系统。 使用 dism /online /cleanup-image /restorehealth 可以修复系统。 [......] 继续阅读

2020年4月4日 0条评论 4215点热度 5人点赞 痴者工良 阅读全文

[5 Minutes] Rookie Study on Design Patterns: Six Design Principles [TOC] As a rookie, the author will attempt to explain the characteristics and application scenarios of these principles in simple code and easy-to-understand language. The six principles are th…

2020年4月4日 0条评论 78点热度 1人点赞 痴者工良 阅读全文

[5分钟]菜鸟修研之设计模式:六大设计原则 [TOC] 笔者作为一个菜鸟,会尝试以简单的代码和容易理解的语句去解释这几种原则的特性和应用场景。 这六种原则分别为单一职责原则、接口隔离原则、里氏替换原则、迪米特法则、依赖倒置原则、开闭原则。 单一职责原则 单一职责原则(SRP:Single responsibility principle),规定一个类中应该只有一个原因引起类的变化。 单一职责原则的核心就是解耦和增强内聚性。 问题: // 假设此类是数据库上下文 public class DatabaseContex…

2020年4月4日 0条评论 3148点热度 1人点赞 痴者工良 阅读全文

readonly string ganweiCosr = "AllowSpecificOrigins"; Startup.ConfigureServices 中,添加服务 #if CORS services.AddCors(options => { options.AddPolicy(ganweiCosr, builder => builder.AllowAnyHeader() .AllowAnyMet[......]继续阅读

2020年4月3日 0条评论 6190点热度 7人点赞 痴者工良 阅读全文

Startup 中,添加一个变量 readonly string ganweiCosr = "AllowSpecificOrigins"; Startup.ConfigureServices 中,添加服务 #if CORS services.AddCors(options => { options.AddPolicy(ganweiCosr, builder => builder.AllowAnyHeader()[......]继续阅读

2020年4月3日 0条评论 6188点热度 7人点赞 痴者工良 阅读全文
1323334353654