本文介绍了缺少异步操作文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我找不到关于同步和异步操作的任何文档?
我希望在Visual Studio 2010中找到一个能够缩放和读取的键盘快捷键有关被调用参数的更多信息,但我找不到多少,可以,请你帮忙吗?
I cannot find any documentation on synchronous and asynchronous operations?
I was hoping to find a keyboard shortcut in Visual Studio 2010 that enables me to zoom, and read more information on the parameters being called, but I could not quite find much, can, you help please?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace SyncDelegateReview
{
public delegate int BinaryOp (int x, int y);
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Main() invoked on thread {0}.", Thread.CurrentThread.ManagedThreadId);
//invoke Add in a synchronous manner
BinaryOp b = new BinaryOp(Add);
//invoke Add() on a secondary thread
b = new BinaryOp(Add);
IAsyncResult iftAR = b.BeginInvoke(10, 10, null, null);
//WHAT DO THE LAST TWO PARAMETERS MEAN PLEASE?
Console.WriteLine("Other work on thread in Main(..)");
//obtain result of the Add()
int answer = b.EndInvoke(iftAR);
Console.WriteLine("10 + 10 is {0} ", answer);
Console.ReadLine();
}
static int Add(int x, int y)
{
//write the ID of the executing thread
Console.WriteLine("Add() invoked on thread {0}", Thread.CurrentThread.ManagedThreadId);
//pause to simulate a lengthy operation
Thread.Sleep(5000);
return x + y;
}
}
}
推荐答案
这篇关于缺少异步操作文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!