本文介绍了与WCF服务共享的变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

有什么办法可以在wcf上共享变量?

示例:

我有这样的wcf服务:

Hi every body,

is there any way to share a variable on wcf?

Example:

I''ve a wcf service like this:

[ServiceContract]
interface Iwcfservice
{
     [ContractOperation]
     void method1();

     [ContractOperation]
     void method2();
}

class wcfservice : Iwcfservice
{
     public void method1()
     {
     }

     public void method2()
     {
     }
}



现在,我希望method1()和method2()使用共享变量.我怎样才能做到这一点?据我所知,method1()和method2()将在两个线程中调用.



Now, i would like method1() and method2() to use a shared variable. How can i do that? According to my knowledge, method1() and method2() will be called in two thread.

推荐答案


[ServiceContract]
interface Iwcfservice
{
     [ContractOperation]
     void method1();
 
     [ContractOperation]
     void method2();
 int Count { get; set; } // Property interface
 string Name { get; set; } // Property interface 

}


这篇关于与WCF服务共享的变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 13:31