我开始学习 ASP.NET Core,在 Web API 模板的框架内,有一个Startup类,其中ConfigureServices()定义了方法。有人可以用简单的语言解释他设置了哪些服务,以及他们为什么需要这些服务吗?谢谢!
有一个TcpListener类的服务器.它使用BeginAcceptTcpClient(AsyncCallback,Object)方法接受传入连接.
代码写在示例MSDN中
public static ManualResetEvent tcpClientConnected =
new ManualResetEvent(false);
public static void DoBeginAcceptTcpClient(TcpListener
listener)
{
while(true)
{
tcpClientConnected.Reset();
Console.WriteLine("Waiting for a connection...");
listener.BeginAcceptTcpClient(
new AsyncCallback(DoAcceptTcpClientCallback),
listener);
tcpClientConnected.WaitOne();
}
}
public static void DoAcceptTcpClientCallback(IAsyncResult ar)
{
TcpListener listener = (TcpListener) ar.AsyncState;
TcpClient client = listener.EndAcceptTcpClient(ar);
Console.WriteLine("Client connected completed");
tcpClientConnected.Set();
while(true)
{
//Receiving messages from the client
}
}
Run Code Online (Sandbox Code Playgroud)
问题是DoAcceptTcpClientCallback(IAsyncResult ar)方法有时会在当前线程(main)中开始执行,而不是在新线程中执行,并阻塞它(main).因此,无法接收以下连接.请帮助理解为什么不为此方法创建线程
Сan我动画Grid.Column财产?我需要进入<Border>专栏.
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="Grid.Column" To="4" Duration="0:0:0.3"/>
</Storyboard>
Run Code Online (Sandbox Code Playgroud)