Click here to Skip to main content
14,391,240 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a WCF service, every 30 seconds it pushes the status to connected clients
my service code here:
private void StartStatusPushing(int callBackInterval)
        {
            Task.Factory.StartNew(
                () =>
                {                    
                    while (true)
                    {
                        Thread.Sleep(callBackInterval);
                        // come code here.
                    }
                },
                TaskCreationOptions.LongRunning);
        }

I have a client application and get the status every 30 seconds via callback channel.

I have a problem like this:
1. At first time started the service and started the client
2. service pushing the updates and client receiving the updates.
3. Then i closed the client and start again without closing the service
4. Then service is not pushing anymore (generally after x second the publish method should run).

so how resolve the issues.

What I have tried:

previously I have a one client application, but now I have 2 application so both should get the updates
Posted
Updated 3-Dec-19 19:39pm
v2
Comments
Richard Deeming 3-Dec-19 10:14am
   
NB: Your method keeps one thread permanently sleeping just to invoke some code every few seconds. It would probably be a better idea to use a Timer[^] instead.
Rate this:
Please Sign up or sign in to vote.

Solution 1

I think your WCF went to an invalid state after client closed. That means you cannot use that previous WCF proxy anymore.
   
Comments
sheik SHA 3-Dec-19 4:39am
   
Is there any way to fix it?
Rate this:
Please Sign up or sign in to vote.

Solution 2

Thank you i found it :)

in code i set a ClosedTimeout is 10 minutes, so its not publishing the status update to next 10 minutes, so i set it to 10 seconds its working as expected

Thank you so much for your support.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100