小编Ron*_*nin的帖子

C#代码优化导致Interlocked.Exchange()出现问题

我有一些代码令人沮丧的问题,不知道为什么会出现这个问题.

//
// .NET FRAMEWORK v4.6.2 Console App

static void Main( string[] args )
{
    var list = new List<string>{ "aa", "bbb", "cccccc", "dddddddd", "eeeeeeeeeeeeeeee", "fffff", "gg" };

    foreach( var item in list )
    {
        Progress( item );
    }
}

private static int _cursorLeft = -1;
private static int _cursorTop = -1;
public static void Progress( string value = null )
{
    lock( Console.Out )
    {
        if( !string.IsNullOrEmpty( value ) )
        {
            Console.Write( value );
            var left = Console.CursorLeft;
            var …
Run Code Online (Sandbox Code Playgroud)

c# optimization release interlocked

10
推荐指数
1
解决办法
327
查看次数

标签 统计

c# ×1

interlocked ×1

optimization ×1

release ×1