看SDK关于这个类的介绍,说这个类型的实例成员是不保证线性安全的,而且如果每次为请求创建一个实例是很耗资源的,所以我用单例模式创建了一个它的实例,然后查询数据,并且在使用实例成员的时候都加了锁,如 :
lock (lockHelper){
guid = (_service as OrganizationServiceProxy).Create(_entity);
}
后来使用了SDK下面的一个工具类 Tools\PluginRegistration,然后代码就改成了这样:
lock (lockHelper){
orgResponse = (_service as ManagedTokenOrganizationServiceProxy).Execute(request);
}
这样就会一直保持和crm是连接的状态,不知道会不会有问题?但是现在我总是得到一个超时的错误都是在使用这个类去查询或者做Create或者Update的时候:
The request channel timed out while waiting for a reply after 00:01:59.9978516. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion
of a longer timeout.
所以我想问的是,关于OrganizationServiceProxy应该怎么用,每次创建一个新的实例,还是只创建一个实例,在使用它的实例成员的时候是否应该加lock?关于这个超时的问题应该怎么解决?
谢谢!