Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a WCF service, every 30 seconds it pushes the status to connected clients
my service code here:
C#
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 18: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.

I think your WCF went to an invalid state after client closed. That means you cannot use that previous WCF proxy anymore.
 
Share this answer
 
Comments
sheik SHA 3-Dec-19 4:39am    
Is there any way to fix it?
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900