保存に問題があります。負荷テストを開始し、GetRolesForUser のテストを開始したことを調査するには、次のようにします。
public override bool IsUserInRole(string username, string roleName)
{
object stub = new object();
bool res;
lock(stub)
{
RoleProviderCount++;
ThreadId = Thread.CurrentThread.ManagedThreadId;
res = GetRolesForUser(username).Contains(roleName);
}
return res;
}
これは私のログです:
Timestamp: 06.11.2012 13:55:03 Message: ServiceCalls count 1; RoleProvider count 1 Thread Id 9
Timestamp: 06.11.2012 14:00:22 Message: ServiceCalls count 1; RoleProvider count 1 Thread Id 9
Timestamp: 07.11.2012 5:30:38 Message: ServiceCalls count 1; RoleProvider count 1 Thread Id 11
Timestamp: 07.11.2012 5:31:58 Message: ServiceCalls count 1; RoleProvider count 4 Thread Id 27
Timestamp: 07.11.2012 5:31:58 Message: ServiceCalls count 1; RoleProvider count 4 Thread Id 27
Timestamp: 07.11.2012 5:31:58 Message: ServiceCalls count 1; RoleProvider count 4 Thread Id 27
Timestamp: 07.11.2012 5:31:58 Message: ServiceCalls count 1; RoleProvider count 4 Thread Id 27
Timestamp: 07.11.2012 5:31:58 Message: ServiceCalls count 1; RoleProvider count 4 Thread Id 27
Timestamp: 07.11.2012 5:31:58 Message: ServiceCalls count 1; RoleProvider count 4 Thread Id 27
Timestamp: 07.11.2012 5:31:59 Message: ServiceCalls count 1; RoleProvider count 5 Thread Id 22
Timestamp: 07.11.2012 5:31:59 Message: ServiceCalls count 1; RoleProvider count 8 Thread Id 26
Timestamp: 07.11.2012 5:31:59 Message: ServiceCalls count 1; RoleProvider count 8 Thread Id 26
Timestamp: 07.11.2012 5:32:00 Message: ServiceCalls count 1; RoleProvider count 10 Thread Id 23
Timestamp: 07.11.2012 5:32:00 Message: ServiceCalls count 1; RoleProvider count 11 Thread Id 29
Timestamp: 07.11.2012 5:32:00 Message: ServiceCalls count 1; RoleProvider count 12 Thread Id 22
Timestamp: 07.11.2012 5:32:00 Message: ServiceCalls count 1; RoleProvider count 13 Thread Id 27
Timestamp: 07.11.2012 5:32:00 Message: ServiceCalls count 1; RoleProvider count 14 Thread Id 24
Timestamp: 07.11.2012 5:32:00 Message: ServiceCalls count 1; RoleProvider count 15 Thread Id 30
Timestamp: 07.11.2012 5:32:00 Message: ServiceCalls count 1; RoleProvider count 16 Thread Id 26
Timestamp: 07.11.2012 5:32:01 Message: ServiceCalls count 1; RoleProvider count 17 Thread Id 11
Timestamp: 07.11.2012 5:32:01 Message: ServiceCalls count 1; RoleProvider count 18 Thread Id 23
Timestamp: 07.11.2012 5:32:01 Message: ServiceCalls count 1; RoleProvider count 20 Thread Id 26
Timestamp: 07.11.2012 5:32:01 Message: ServiceCalls count 1; RoleProvider count 20 Thread Id 26
Timestamp: 07.11.2012 5:32:01 Message: ServiceCalls count 1; RoleProvider count 21 Thread Id 24
したがって、 RoleProvider メソッドは同じスレッドから呼び出されました。(WCF サービス構成インスタンス モード PerCall、同時実行数 Multiple)