Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
02502089
Commit
02502089
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Clean local PerformanceCounter stuff from ATxService.
parent
16815f4a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxService/AutoTx.cs
+1
-32
1 addition, 32 deletions
ATxService/AutoTx.cs
with
1 addition
and
32 deletions
ATxService/AutoTx.cs
+
1
−
32
View file @
02502089
...
...
@@ -44,9 +44,6 @@ namespace ATxService
private
long
_txCurFileSize
;
private
int
_txCurFileProgress
;
private
int
_waitCyclesBeforeNextTx
;
public
PerformanceCounter
CpuCounter
;
private
float
_cpuLoad
;
private
readonly
float
[]
_cpuLoadLastReadings
=
{
0F
,
0F
,
0F
,
0F
};
private
Cpu
_cpu
;
private
DateTime
_lastUserDirCheck
=
DateTime
.
MinValue
;
...
...
@@ -77,7 +74,6 @@ namespace ATxService
private
ServiceStatus
_status
;
private
static
Timer
_mainTimer
;
private
static
Timer
_loadTimer
;
#
endregion
...
...
@@ -92,12 +88,6 @@ namespace ATxService
SetupFileLogging
();
Log
.
Info
(
"="
.
PadLeft
(
80
,
'='
));
Log
.
Info
(
"Attempting to start {0} service..."
,
ServiceName
);
try
{
CpuCounter
=
new
PerformanceCounter
(
"Processor"
,
"% Processor Time"
,
"_Total"
);
}
catch
(
Exception
ex
)
{
Log
.
Error
(
"initializing PerformanceCounter failed: {0}"
,
ex
.
Message
);
}
CreateEventLog
();
LoadSettings
();
CreateIncomingDirectories
();
...
...
@@ -378,24 +368,6 @@ namespace ATxService
#
endregion
private
void
UpdateCpuLoad
(
object
sender
,
ElapsedEventArgs
elapsedEventArgs
)
{
_loadTimer
.
Enabled
=
false
;
try
{
Log
.
Trace
(
"UpdateCpuLoad(), old values: {0}, average: {1}"
,
string
.
Join
(
", "
,
_cpuLoadLastReadings
),
_cpuLoadLastReadings
.
Average
());
Array
.
ConstrainedCopy
(
_cpuLoadLastReadings
,
1
,
_cpuLoadLastReadings
,
0
,
3
);
_cpuLoadLastReadings
[
3
]
=
CpuCounter
.
NextValue
();
_cpuLoad
=
_cpuLoadLastReadings
.
Average
();
Log
.
Trace
(
"UpdateCpuLoad(), new values: {0}, average: {1}"
,
string
.
Join
(
", "
,
_cpuLoadLastReadings
),
_cpuLoadLastReadings
.
Average
());
}
catch
(
Exception
ex
)
{
Log
.
Error
(
"UpdateCpuLoad failed: {0}"
,
ex
.
Message
);
}
finally
{
_loadTimer
.
Enabled
=
true
;
}
}
#
region
overrides
for
ServiceBase
methods
(
start
,
stop
,
...)
...
...
@@ -408,9 +380,6 @@ namespace ATxService
_mainTimer
.
Elapsed
+=
OnTimedEvent
;
_mainTimer
.
Enabled
=
true
;
_loadTimer
=
new
Timer
(
250
);
_loadTimer
.
Elapsed
+=
UpdateCpuLoad
;
_loadTimer
.
Enabled
=
true
;
_cpu
=
new
Cpu
();
}
...
...
@@ -503,7 +472,7 @@ namespace ATxService
// while this method has not finished yet:
_mainTimer
.
Enabled
=
false
;
Log
.
Debug
(
"CPU load: {0:#
} / {1:#} ({2:#
.##}
)
"
,
_cpuLoad
,
_cpu
.
Load
(),
_cpuLoad
-
_cpu
.
Load
());
Log
.
Debug
(
"CPU load: {0:#.##}"
,
_cpu
.
Load
());
try
{
RunMainTasks
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment