我有一个带有此指令的aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Logs.aspx.cs" Inherits="Logs_Logs" Async="true" %>
和.cs:
.....
private readonly Action<string> zipArquivoAction;
public Logs_Logs()
{
zipArquivoAction = ZipArquivo;
}
protected void LkbGZip_Click(object sender, EventArgs e)
{
LinkButton lkbGZip = (LinkButton) sender;
AddOnPreRenderCompleteAsync(BeginAsyncOperation, EndAsyncOperation, lkbGZip.CommandArgument);
}
IAsyncResult BeginAsyncOperation(object sender, EventArgs e, AsyncCallback cb, object state)
{
return zipArquivoAction.BeginInvoke((string)state, cb, state);
}
void EndAsyncOperation(IAsyncResult ar)
{
zipArquivoAction.EndInvoke(ar);
}
private void ZipArquivo(string arquivoCaminho)
{
System.Threading.Thread.Sleep(10000);
}
如果我在任何方法中放置一个断点并调用System.Threading.Thread.CurrentThread,总是返回相同的Thread,这意味着我没有使用IO Thread,对吧?
System.Threading.Thread.CurrentThread
{System.Threading.Thread}
base {System.Runtime.ConstrainedExecution.CriticalFinalizerObject}:
{System.Threading.Thread}
ApartmentState: MTA
CurrentCulture: {pt-BR}
CurrentUICulture: {pt-BR}
ExecutionContext: {System.Threading.ExecutionContext}
IsAlive: true
IsBackground: true
IsThreadPoolThread: true
ManagedThreadId: 5
Name: null
Priority: Normal
ThreadState: Background
答案 0 :(得分:1)
启用跟踪并查找对Begin AsyncOperation和End AsyncOperation的调用。这些应该出现在End PreRender之后。
了解更多信息: