[Mono-dev] WCF and parallel client-execution

Chakotey STME chakoteystme at gmail.com
Sat Nov 20 18:10:39 EST 2010


Hello,

I have a problem with WCF.

I have a service:


<ServiceBehavior(ConcurrencyMode:=ServiceModel.ConcurrencyMode.Multiple,
InstanceContextMode:=InstanceContextMode.Single)> _
Public Class HelloService
  Implements IHelloService


  Private Shared thisInstance As HelloService
  Protected Sub New()
    Console.WriteLine("Service erzeugt!")


  End Sub

  'singleton
  Public Shared Function GetSingleton() As HelloService
    If (thisInstance Is Nothing) Then
      thisInstance = New HelloService
    End If
    Return thisInstance
  End Function

  Public Function Greet(ByVal name As String) As IList(Of Objekt)
Implements IHelloService.Greet

    Console.WriteLine("greet aufgerufen! " & DateTime.Now.Ticks)

    Dim myObjekt As Objekt = New Objekt
    Dim myObjekt2 As Objekt = New Objekt


    Console.WriteLine("Service macht etwas lang dauerndes")

    Dim i As UInteger = 0
    For i = 0 To UInteger.MaxValue / 2

    Next

    Console.WriteLine("dauert lange fertig")

    Dim list As List(Of Objekt) = New List(Of Objekt)
    list.Add(myObjekt)
    list.Add(myObjekt2)



    Return list


  End Function



  Public Function Greet2(ByVal name As String) As
System.Collections.Generic.IList(Of Contracts.Objekt) Implements
Contracts.IHelloService.Greet2
    Console.WriteLine("greet2 aufgerufen! " & DateTime.Now.Ticks)

    Dim myObjekt As Objekt = New Objekt
    Dim myObjekt2 As Objekt = New Objekt


    Console.WriteLine("Service2 macht etwas lang dauerndes")

    Dim i As UInteger = 0
    For i = 0 To UInteger.MaxValue / 2

    Next

    Console.WriteLine("dauert lange fertig")

    Dim list As List(Of Objekt) = New List(Of Objekt)
    list.Add(myObjekt)
    list.Add(myObjekt2)

    Return list
  End Function
End Class

And I have a Client:


Imports System.ServiceModel
Imports Contracts

Module Module1

  Sub Main()
    Dim binding = New BasicHttpBinding()
    Dim address = New EndpointAddress("http://192.168.100.110:8080")
    Dim client = New HelloClient(binding, address)

    Dim myObjekt = client.Greet("name")
  End Sub
End Module

If I execute the client I get a answer from the host and all is perfect.

But I want that more than one client can connect to the service and
use the methods from the singleton service.

If I execute two clients - one client has to wait until the other
client has his return value.

I don't know why, because I used the attribute


ConcurrencyMode:=ServiceModel.ConcurrencyMode.Multiple

I use a basicHttpBinding and the service is hosted via a
windows-service with mono-service2.

So can you help me?

I use vb.net 3.5

Thanks,


More information about the Mono-devel-list mailing list