2
통화 시간 WCF 서비스 메서드의 성능 카운터를 측정하려고합니다.비동기 WCF 서비스 및 통화 기간 성능 카운터
다음과 같이 매우 간단한 WCF 서비스가 있습니다.
서비스 인터페이스 :
[ServiceContract]
public interface IFooService
{
[OperationContract]
string DoSomeExpensiveOperation();
}
서비스 구현 :
public class FooService : IFooService
{
public string DoSomeExpensiveOperation()
{
Thread.Sleep(3000);
return "Some valuable information";
}
}
(위의 주어진) 구현이 동기, 나는 통화 시간이 채워되는 것을 볼 수 있습니다.
그러나 서비스 구현이 비동기 (아래 명시된대로) 인 경우 아무 것도 채워지지 않습니다.
서비스 인터페이스 :
[ServiceContract]
public interface IFooService
{
[OperationContract]
Task<string> DoSomeExpensiveOperation();
}
서비스 구현 : 나는 심지어 await를 한 후 사용자 정의 성능 카운터를 게시하려고했습니다
public class FooService : IFooService
{
public async Task<string> DoSomeExpensiveOperation()
{
Thread.Sleep(3000);
return await Task.FromResult("Some expensive value");
}
}
. 심지어 이것은 작동하지 않았다.
누구든지이 점을 밝힐 수 있으면 감사하게 생각합니다.
감사합니다.