Click here to Skip to main content
15,895,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a Problem with my current project ,

It is a Desktop App,

I was create a project that connected my application with XSolution 901,

My App is get data from the machine using ZKEMKEEPER Library,
to make the data RealTime i create a job that run every 1 seconds using timer.tick

This is my code

timer20.Enabled = true;
            timer20.Start();
            timer20.Tick += (source, es) =>
            {
                timer20.Interval = 1000; GetdataMachine(); GetDataLog5Machine();
            };


What I have tried:

the problem is that the application will be stop working after one day ,or showing error like this

"
The Semaphone Timeout Period
"

How can i solve this?
Posted
Updated 7-Mar-21 20:04pm
Comments
Sandeep Mewara 8-Mar-21 0:03am    
1 second polling is way too resource hogging, keep aside the time it might take to respond. Increase time for the job to check and see.

1 solution

Without being able to see what GetdataMachine and GetDataLog5Machine do and how they do it, we really can't help you with anything specific.
But the first thing I'd do is move the Interval property setting outside the Tick event handler, it should be set before the timer is started, and the handler should be configured before then as well.
That won't fix your problem, but it'll make your code more professional ...

The error message isn't too helpful, even if you read the actual message, which is probably "Semaphore timeout period has expired" rather than "Semaphone timeout period" because we have no idea what semaphores are in use.
Probably, your code is loading up the network with massive data transfers which are just slowing everything down to the point where the network IO part of the OS is timing out on responses from the target machine - and one easy way to do that is to use threading in your methods. If the copy operation exceeds 1 second (which isn't difficult with large files) then a second timer event happens before the first is complete and things all start to slide from there.

So start by looking at what your methods do and exactly how they do it: consider how often things need to be checked, and what effects multitasking, memory, disk, and network loading will have on operations. You need to think of this as a whole system including both the app computer, the target computer, and the network between them to get any idea what might be happening here!
Sorry, but we can't do any of that for you!
 
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