[Mono-osx] Mono - WCF

Sheen Chandy sheenchandy at verifaya.com
Wed Oct 17 05:32:55 UTC 2012


Hi,

Thanks for you reply.

I tried with changing instance-context and still it is taking long
time to get called.
Actually i required concurrency here (that is why i used
InstanceContextMode.PerCall). When first function
(LongRunningFunction()) is running I need to call my second function
(StopLongRunningFunction()).
I am sorry i made one mistake in my sample code, the 'Thread' i am
creating in LongRunningFunction() is actually a static one so that
every instance can access that thread.

Thanks &  Regards
Sheen

On Wed, Oct 17, 2012 at 12:04 AM, Adam <adam at irisdesign.co.nz> wrote:
> hi,
>
> Your problem is, your WCF setup doesnt make sense for your purpose.
> You are using:
> InstanceContextMode=InstanceContextMode.PerCall
>
> This means that a new instance of your service class is instantiated every
> time a request comes in - so you will never be able to refer to an instance
> of the service that started the thread (i.e., you will set ' needToExit =
> true;' inside of a service that has just been created, and has no running
> thread).
>
> You need to change to another instance-context, such as Single, or
> PerSession.
>
> Adam
>
> On Wed, Oct 17, 2012 at 12:31 AM, sheen <sheenchandy at verifaya.com> wrote:
>>
>> Hi,
>>
>> I have an issue in calling WCF Services.
>> I will explain issue using below example
>>
>> WCF Interface :
>>
>> [ServiceContract]
>> public interface IWcfServer
>> {
>>         [OperationContract]
>>         void LongRunningFunction();
>>         [OperationContract]
>>         void StopLongRunningFunction();
>> }
>>
>> WCF Service :
>>
>>
>> [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall,ConcurrencyMode=ConcurrencyMode.Multiple)]
>> public class WfcServer : IWcfServer
>> {
>>         public static bool needToExit = false;
>>         public void LongRunningFunction()
>>         {
>>                 Thread t = new Thread(LongRunningProcess);
>>                 t.Start();
>>                 t.Join();
>>         }
>>         public void StopLongRunningFunction()
>>         {
>>                 needToExit = true;
>>         }
>>         private void LongRunningProcess ()
>>         {
>>                 while (true) {
>>                         if(needToExit)
>>                                   break;
>>                         System.Threading.Thread.Sleep(1000);
>>                 }
>>         }
>> }
>>
>> Config file
>>
>> <?xml version="1.0" encoding="utf-8" ?>
>> <configuration>
>>   <system.serviceModel>
>>     <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
>>     <behaviors>
>>       <serviceBehaviors>
>>         <behavior name="SampleWcf.WfcServerBehavior">
>>           <serviceMetadata httpGetEnabled="true" />
>>           <serviceDebug includeExceptionDetailInFaults="true" />
>>         </behavior>
>>       </serviceBehaviors>
>>       <endpointBehaviors>
>>         <behavior name="webHttpBehavior">
>>           <webHttp />
>>         </behavior>
>>       </endpointBehaviors>
>>     </behaviors>
>>     <bindings>
>>       <webHttpBinding>
>>         <binding name="webHttpBind"/>
>>       </webHttpBinding>
>>     </bindings>
>>     <services>
>>       <service name="SampleWcf.WfcServer"
>> behaviorConfiguration="SampleWcf.WfcServerBehavior">
>>         <endpoint name="WfcServer" address="" binding="webHttpBinding"
>>                   bindingConfiguration="webHttpBind"
>> contract="WcfInterface.IWcfServer"
>>                   behaviorConfiguration="webHttpBehavior"/>
>>       </service>
>>     </services>
>>   </system.serviceModel>
>> </configuration>
>>
>> WCF Client:
>>
>> From WCF Client first i will call LongRunningFunction() and then
>> StopLongRunningFunction(). My issue is in calling
>> StopLongRunningFuction().
>> StopLongRunningFuction() get called after a long time (nearly 5 min).
>> Please help me to resolve this issue.
>>
>>
>> Thanks & Regards
>> Sheen
>>
>>
>>
>>
>> --
>> View this message in context:
>> http://mono.1490590.n4.nabble.com/Mono-WCF-tp4656979.html
>> Sent from the Mono - OSX mailing list archive at Nabble.com.
>> _______________________________________________
>> Mono-osx mailing list
>> Mono-osx at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-osx
>>
>
>
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
>


More information about the Mono-osx mailing list