5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-10 22:19:46 +08:00
wails/v3/examples/cancel-async/service.go
2025-04-25 20:51:34 +10:00

20 lines
345 B
Go

package main
import (
"context"
"time"
)
type Service struct {
}
// LongRunning - 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()
}
}