mail-archives/mono-osx/2012-October/005102.html

209 строки
9.0 KiB
HTML
Исходник Обычный вид История

2019-06-06 22:05:17 +03:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE> [Mono-osx] Mono - WCF
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:mono-osx%40lists.ximian.com?Subject=Re%3A%20%5BMono-osx%5D%20Mono%20-%20WCF&In-Reply-To=%3CCACR7UhBxk3fj2TpUKeRqho2ayNC4-mTk%2BU6ejN8j6c%2BW%2BG5ytg%40mail.gmail.com%3E">
<META NAME="robots" CONTENT="index,nofollow">
<style type="text/css">
pre {
white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */
}
</style>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="005101.html">
<LINK REL="Next" HREF="005103.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[Mono-osx] Mono - WCF</H1>
<B>Sheen Chandy</B>
<A HREF="mailto:mono-osx%40lists.ximian.com?Subject=Re%3A%20%5BMono-osx%5D%20Mono%20-%20WCF&In-Reply-To=%3CCACR7UhBxk3fj2TpUKeRqho2ayNC4-mTk%2BU6ejN8j6c%2BW%2BG5ytg%40mail.gmail.com%3E"
TITLE="[Mono-osx] Mono - WCF">sheenchandy at verifaya.com
</A><BR>
<I>Wed Oct 17 05:32:55 UTC 2012</I>
<P><UL>
<LI>Previous message: <A HREF="005101.html">[Mono-osx] Mono - WCF
</A></li>
<LI>Next message: <A HREF="005103.html">[Mono-osx] Mono.Cecil.ResolutionException when packaging for .Net 4.5
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#5102">[ date ]</a>
<a href="thread.html#5102">[ thread ]</a>
<a href="subject.html#5102">[ subject ]</a>
<a href="author.html#5102">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>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 &amp; Regards
Sheen
On Wed, Oct 17, 2012 at 12:04 AM, Adam &lt;<A HREF="http://lists.ximian.com/mailman/listinfo/mono-osx">adam at irisdesign.co.nz</A>&gt; wrote:
&gt;<i> hi,
</I>&gt;<i>
</I>&gt;<i> Your problem is, your WCF setup doesnt make sense for your purpose.
</I>&gt;<i> You are using:
</I>&gt;<i> InstanceContextMode=InstanceContextMode.PerCall
</I>&gt;<i>
</I>&gt;<i> This means that a new instance of your service class is instantiated every
</I>&gt;<i> time a request comes in - so you will never be able to refer to an instance
</I>&gt;<i> of the service that started the thread (i.e., you will set ' needToExit =
</I>&gt;<i> true;' inside of a service that has just been created, and has no running
</I>&gt;<i> thread).
</I>&gt;<i>
</I>&gt;<i> You need to change to another instance-context, such as Single, or
</I>&gt;<i> PerSession.
</I>&gt;<i>
</I>&gt;<i> Adam
</I>&gt;<i>
</I>&gt;<i> On Wed, Oct 17, 2012 at 12:31 AM, sheen &lt;<A HREF="http://lists.ximian.com/mailman/listinfo/mono-osx">sheenchandy at verifaya.com</A>&gt; wrote:
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> Hi,
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> I have an issue in calling WCF Services.
</I>&gt;&gt;<i> I will explain issue using below example
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> WCF Interface :
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> [ServiceContract]
</I>&gt;&gt;<i> public interface IWcfServer
</I>&gt;&gt;<i> {
</I>&gt;&gt;<i> [OperationContract]
</I>&gt;&gt;<i> void LongRunningFunction();
</I>&gt;&gt;<i> [OperationContract]
</I>&gt;&gt;<i> void StopLongRunningFunction();
</I>&gt;&gt;<i> }
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> WCF Service :
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> [ServiceBehavior(InstanceContextMode=InstanceContextMode.PerCall,ConcurrencyMode=ConcurrencyMode.Multiple)]
</I>&gt;&gt;<i> public class WfcServer : IWcfServer
</I>&gt;&gt;<i> {
</I>&gt;&gt;<i> public static bool needToExit = false;
</I>&gt;&gt;<i> public void LongRunningFunction()
</I>&gt;&gt;<i> {
</I>&gt;&gt;<i> Thread t = new Thread(LongRunningProcess);
</I>&gt;&gt;<i> t.Start();
</I>&gt;&gt;<i> t.Join();
</I>&gt;&gt;<i> }
</I>&gt;&gt;<i> public void StopLongRunningFunction()
</I>&gt;&gt;<i> {
</I>&gt;&gt;<i> needToExit = true;
</I>&gt;&gt;<i> }
</I>&gt;&gt;<i> private void LongRunningProcess ()
</I>&gt;&gt;<i> {
</I>&gt;&gt;<i> while (true) {
</I>&gt;&gt;<i> if(needToExit)
</I>&gt;&gt;<i> break;
</I>&gt;&gt;<i> System.Threading.Thread.Sleep(1000);
</I>&gt;&gt;<i> }
</I>&gt;&gt;<i> }
</I>&gt;&gt;<i> }
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> Config file
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
</I>&gt;&gt;<i> &lt;configuration&gt;
</I>&gt;&gt;<i> &lt;system.serviceModel&gt;
</I>&gt;&gt;<i> &lt;serviceHostingEnvironment aspNetCompatibilityEnabled=&quot;true&quot; /&gt;
</I>&gt;&gt;<i> &lt;behaviors&gt;
</I>&gt;&gt;<i> &lt;serviceBehaviors&gt;
</I>&gt;&gt;<i> &lt;behavior name=&quot;SampleWcf.WfcServerBehavior&quot;&gt;
</I>&gt;&gt;<i> &lt;serviceMetadata httpGetEnabled=&quot;true&quot; /&gt;
</I>&gt;&gt;<i> &lt;serviceDebug includeExceptionDetailInFaults=&quot;true&quot; /&gt;
</I>&gt;&gt;<i> &lt;/behavior&gt;
</I>&gt;&gt;<i> &lt;/serviceBehaviors&gt;
</I>&gt;&gt;<i> &lt;endpointBehaviors&gt;
</I>&gt;&gt;<i> &lt;behavior name=&quot;webHttpBehavior&quot;&gt;
</I>&gt;&gt;<i> &lt;webHttp /&gt;
</I>&gt;&gt;<i> &lt;/behavior&gt;
</I>&gt;&gt;<i> &lt;/endpointBehaviors&gt;
</I>&gt;&gt;<i> &lt;/behaviors&gt;
</I>&gt;&gt;<i> &lt;bindings&gt;
</I>&gt;&gt;<i> &lt;webHttpBinding&gt;
</I>&gt;&gt;<i> &lt;binding name=&quot;webHttpBind&quot;/&gt;
</I>&gt;&gt;<i> &lt;/webHttpBinding&gt;
</I>&gt;&gt;<i> &lt;/bindings&gt;
</I>&gt;&gt;<i> &lt;services&gt;
</I>&gt;&gt;<i> &lt;service name=&quot;SampleWcf.WfcServer&quot;
</I>&gt;&gt;<i> behaviorConfiguration=&quot;SampleWcf.WfcServerBehavior&quot;&gt;
</I>&gt;&gt;<i> &lt;endpoint name=&quot;WfcServer&quot; address=&quot;&quot; binding=&quot;webHttpBinding&quot;
</I>&gt;&gt;<i> bindingConfiguration=&quot;webHttpBind&quot;
</I>&gt;&gt;<i> contract=&quot;WcfInterface.IWcfServer&quot;
</I>&gt;&gt;<i> behaviorConfiguration=&quot;webHttpBehavior&quot;/&gt;
</I>&gt;&gt;<i> &lt;/service&gt;
</I>&gt;&gt;<i> &lt;/services&gt;
</I>&gt;&gt;<i> &lt;/system.serviceModel&gt;
</I>&gt;&gt;<i> &lt;/configuration&gt;
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> WCF Client:
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> From WCF Client first i will call LongRunningFunction() and then
</I>&gt;&gt;<i> StopLongRunningFunction(). My issue is in calling
</I>&gt;&gt;<i> StopLongRunningFuction().
</I>&gt;&gt;<i> StopLongRunningFuction() get called after a long time (nearly 5 min).
</I>&gt;&gt;<i> Please help me to resolve this issue.
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> Thanks &amp; Regards
</I>&gt;&gt;<i> Sheen
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i>
</I>&gt;&gt;<i> --
</I>&gt;&gt;<i> View this message in context:
</I>&gt;&gt;<i> <A HREF="http://mono.1490590.n4.nabble.com/Mono-WCF-tp4656979.html">http://mono.1490590.n4.nabble.com/Mono-WCF-tp4656979.html</A>
</I>&gt;&gt;<i> Sent from the Mono - OSX mailing list archive at Nabble.com.
</I>&gt;&gt;<i> _______________________________________________
</I>&gt;&gt;<i> Mono-osx mailing list
</I>&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/mono-osx">Mono-osx at lists.ximian.com</A>
</I>&gt;&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/mono-osx">http://lists.ximian.com/mailman/listinfo/mono-osx</A>
</I>&gt;&gt;<i>
</I>&gt;<i>
</I>&gt;<i>
</I>&gt;<i> _______________________________________________
</I>&gt;<i> Mono-osx mailing list
</I>&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/mono-osx">Mono-osx at lists.ximian.com</A>
</I>&gt;<i> <A HREF="http://lists.ximian.com/mailman/listinfo/mono-osx">http://lists.ximian.com/mailman/listinfo/mono-osx</A>
</I>&gt;<i>
</I></PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="005101.html">[Mono-osx] Mono - WCF
</A></li>
<LI>Next message: <A HREF="005103.html">[Mono-osx] Mono.Cecil.ResolutionException when packaging for .Net 4.5
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#5102">[ date ]</a>
<a href="thread.html#5102">[ thread ]</a>
<a href="subject.html#5102">[ subject ]</a>
<a href="author.html#5102">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.ximian.com/mailman/listinfo/mono-osx">More information about the Mono-osx
mailing list</a><br>
</body></html>