Skip to content

Commit 7ca1f35

Browse files
authored
Merge pull request #34 from arduino/scerza/fix-windows-cpu-consumption
Fix high CPU consumption on Windows
2 parents a7e7132 + fd5a4ff commit 7ca1f35

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: sync/sync_windows.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"runtime"
2424
"syscall"
25+
"time"
2526
"unsafe"
2627

2728
discovery "github.com/arduino/pluggable-discovery-protocol-handler/v2"
@@ -131,7 +132,8 @@ func Start(eventCB discovery.EventCallback, errorCB discovery.ErrorCallback) (ch
131132
if !ev {
132133
return
133134
}
134-
default:
135+
case <-time.After(time.Millisecond * 500):
136+
// Use a small timeout instead of default case to avoid high CPU consumption
135137
}
136138
updates, err := enumerator.GetDetailedPortsList()
137139
if err != nil {

0 commit comments

Comments
 (0)