hi,<div><br></div><div>Your problem is, your WCF setup doesnt make sense for your purpose.</div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">You are using:</span></div>
<div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">InstanceContextMode=</span><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)">InstanceContextMode.PerCall</span><br>
<br>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 '<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:13px;background-color:rgb(255,255,255)"> needToExit = true;' inside of a service that has just been created, and has no running thread).</span></div>
<div><font color="#222222" face="arial, sans-serif"><br></font></div><div><font color="#222222" face="arial, sans-serif">You need to change to another instance-context, such as Single, or PerSession.</font></div><div><font color="#222222" face="arial, sans-serif"><br>
</font></div><div><font color="#222222" face="arial, sans-serif">Adam</font></div><div><font color="#222222" face="arial, sans-serif"><br></font><div class="gmail_quote">On Wed, Oct 17, 2012 at 12:31 AM, sheen <span dir="ltr"><<a href="mailto:sheenchandy@verifaya.com" target="_blank">sheenchandy@verifaya.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have an issue in calling WCF Services.<br>
I will explain issue using below example<br>
<br>
WCF Interface :<br>
<br>
[ServiceContract]<br>
public interface IWcfServer<br>
{<br>
        [OperationContract]<br>
        void LongRunningFunction();<br>
        [OperationContract]<br>
        void StopLongRunningFunction();<br>
}<br>
<br>
WCF Service :<br>
<br>
[ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall,ConcurrencyMode=ConcurrencyMode.Multiple)]<br>
public class WfcServer : IWcfServer<br>
{<br>
        public static bool needToExit = false;<br>
        public void LongRunningFunction()<br>
        {<br>
                Thread t = new Thread(LongRunningProcess);<br>
                t.Start();<br>
                t.Join();<br>
        }<br>
        public void StopLongRunningFunction()<br>
        {<br>
                needToExit = true;<br>
        }<br>
        private void LongRunningProcess ()<br>
        {<br>
                while (true) {<br>
                        if(needToExit)<br>
                                  break;<br>
                        System.Threading.Thread.Sleep(1000);<br>
                }<br>
        }<br>
}<br>
<br>
Config file<br>
<br>
<?xml version="1.0" encoding="utf-8" ?><br>
<configuration><br>
  <system.serviceModel><br>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /><br>
    <behaviors><br>
      <serviceBehaviors><br>
        <behavior name="SampleWcf.WfcServerBehavior"><br>
          <serviceMetadata httpGetEnabled="true" /><br>
          <serviceDebug includeExceptionDetailInFaults="true" /><br>
        </behavior><br>
      </serviceBehaviors><br>
      <endpointBehaviors><br>
        <behavior name="webHttpBehavior"><br>
          <webHttp /><br>
        </behavior><br>
      </endpointBehaviors><br>
    </behaviors><br>
    <bindings><br>
      <webHttpBinding><br>
        <binding name="webHttpBind"/><br>
      </webHttpBinding><br>
    </bindings><br>
    <services><br>
      <service name="SampleWcf.WfcServer"<br>
behaviorConfiguration="SampleWcf.WfcServerBehavior"><br>
        <endpoint name="WfcServer" address="" binding="webHttpBinding"<br>
                  bindingConfiguration="webHttpBind"<br>
contract="WcfInterface.IWcfServer"<br>
                  behaviorConfiguration="webHttpBehavior"/><br>
      </service><br>
    </services><br>
  </system.serviceModel><br>
</configuration><br>
<br>
WCF Client:<br>
<br>
>From WCF Client first i will call LongRunningFunction() and then<br>
StopLongRunningFunction(). My issue is in calling StopLongRunningFuction().<br>
StopLongRunningFuction() get called after a long time (nearly 5 min).<br>
Please help me to resolve this issue.<br>
<br>
<br>
Thanks & Regards<br>
Sheen<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://mono.1490590.n4.nabble.com/Mono-WCF-tp4656979.html" target="_blank">http://mono.1490590.n4.nabble.com/Mono-WCF-tp4656979.html</a><br>
Sent from the Mono - OSX mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Mono-osx mailing list<br>
<a href="mailto:Mono-osx@lists.ximian.com">Mono-osx@lists.ximian.com</a><br>
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx" target="_blank">http://lists.ximian.com/mailman/listinfo/mono-osx</a><br>
<br>
</blockquote></div><br></div>