小编Mag*_*ind的帖子

无法导入System.Windows.Controls

我正在尝试使用System.Windows.Controls.TextChangedEventArgs,但我无法导入System.Windows.Controls.当我尝试添加引用时,System.Windows.Controls不是我可以选择的程序集之一.

有谁知道如何解决这个问题?

.net c# import visual-studio visual-studio-2012

9
推荐指数
2
解决办法
1万
查看次数

何时创建新任务

我正在学习C#.NET 4.5中的任务并行,我对一个例子感到有些困惑.这是我不明白的代码:

public static Task<string> DownloadStringAsync(string address)
{
  // First try to retrieve the content from cache. 
  string content;
  if (cachedDownloads.TryGetValue(address, out content))
  {
     return Task.FromResult<string>(content);
  }

  // If the result was not in the cache, download the  
  // string and add it to the cache. 
  return Task.Run(async () => // why create a new task here?
  {
     content = await new WebClient().DownloadStringTaskAsync(address);
     cachedDownloads.TryAdd(address, content);
     return content;
  });
}
Run Code Online (Sandbox Code Playgroud)

具体来说,我不明白他们为什么要包装DownloadStringTaskAsync()其他任务.还没有DownloadStringTaskAsync()在自己的线程上运行?

这是我编写它的方式:

public static async …
Run Code Online (Sandbox Code Playgroud)

.net c# asynchronous task-parallel-library async-await

7
推荐指数
1
解决办法
1165
查看次数

更改Visual Studio 2012 C#模数格式

如何更改Visual Studio的格式化模数(%)运算符的选项?

例如,每当我键入行

int x = a % b;
Run Code Online (Sandbox Code Playgroud)

Visual Studio将其更改为

int x = a%b;
Run Code Online (Sandbox Code Playgroud)

当我输入分号时.我宁愿它自动在模数运算符周围添加空格而不是将它们带走.

c# resharper visual-studio-2012

4
推荐指数
1
解决办法
335
查看次数