Hi,
I am not sure to understand how to use the push notification with Devforce.
Here is what I can read on the documentation : "A push service is started upon the first client subscription. Once started, the service can run indefinitely and support any number of subscribing clients. The service runs on its own thread and can perform any processing desired, including starting additional threads or processes"
So if I have 2 ViewModel which both want to register to this service, the first call to RegisterCallback will start the method and the second call will add the new subscriber to the subscribers collection.
Here is what I have in my logs :
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationServiceManager:.ctor NotificationServiceManager started
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationServiceManager:.ctor NotificationServiceManager started
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationServiceManager:RegisterUser New user registered for NewDossiers
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationServiceManager:RegisterUser New user registered for NewDossiers
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationThreadHelper:RunServerMethod NewDossiers is starting on thread 22
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.NotificationThreadHelper:RunServerMethod NewDossiers is starting on thread 4
2012-09-06 18:27:03 Administrateur IdeaBlade.EntityModel.Server.EntityServerQueryInterceptor:ExecuteQuery Fetch ... value(IdeaBlade.EntityModel.EntityQueryProxy`1[Domain.Entities.Dossier]).Where(dos => (dos.CreationDate >= 06/09/2012 18:27:03))
We can see the method NewDossiers was started twice on 2 differents thread. Unfortunatly, this cause an exception when I try to query the EntityManager because it is now on the wrong thread.
In both viewmodel, I call the method RegisterCallback with the same parameters except the Usertoken, each VM has his own. This bring me to a question about the usertoken. Is it the way to use the token ?
In the API documentation, you write : "The userToken should be used to identify the client request. It does not have to be unique acrosss all clients, but it must be unique for all requests from a single client"
I am about confuse about the notion of client here. is a ViewModel a client or are you talking about the silverlight application itself ? if I try to register both with the same token it thrown an exception so the sentence confuse me.
So, Is this normal or a bug to see this method on thread 22 then 4 ?
If it is normal, how should I handle such scenario ?
Note :
It doesn't happen all the time, sometimes it start on one thread only.
In my case, both viewmodel register to the service in the same time (they both listen to the same event in my application and once it is raise they call RegisterCallback).