5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 22:13:36 +08:00
wails/v3/examples/cancel-async/service.go
2025-02-25 18:01:36 +01:00

20 lines
331 B
Go

package main
import (
"context"
"time"
)
type Service struct {
}
// A long running operation of specified duration.
func (*Service) LongRunning(ctx context.Context, milliseconds int) error {
select {
case <-time.After(time.Duration(milliseconds) * time.Millisecond):
return nil
case <-ctx.Done():
return ctx.Err()
}
}