0
비동기 작업을 사용하지만 반환하는 IAsyncResult.AsyncState가 항상 null 인 다음 프로그램이 있습니다.왜 내 asyncResult가 항상 null입니까?
내가 뭘 잘못하고있어?
public interface ICommandService
{
[OperationContract(AsyncPattern = true)]
IAsyncResult BeginLogin(string userName, string password, AsyncCallback callback, object state);
string EndLogin(IAsyncResult result);
}
class CommandService : ICommandService
{
public string Login(string userName, string password)
{
return "dorcohen";
}
private Func<string, string, string> _LoginDelgateObject;
public IAsyncResult BeginLogin(string userName, string password, AsyncCallback callback, object state)
{
Func<string, string, string> function = new Func<string, string, string>(Login);
_LoginDelgateObject = function;
IAsyncResult result = function.BeginInvoke(userName, password, callback, state);
return result;
}
public string EndLogin(IAsyncResult result)
{
CommandService test = result.AsyncState as CommandService;
return test._LoginDelgateObject.EndInvoke(result);
}
}
에 다음 코드를 사용하지 못할. 전화 코드를 보여 주시겠습니까? –
@EfranCobisi 감사합니다. 실제로 국가와 관련이 있습니다. –