diff --git a/view.go b/view.go index c9d74a9..07f844c 100644 --- a/view.go +++ b/view.go @@ -40,10 +40,7 @@ func NewForWriter[K comparable](w io.Writer) *View[K] { } func (v *View[K]) Show() { - go func() { - defer close(v.reportCh) - v.wg.Wait() - }() + go v.WaitForAllTasks() for status := range v.reportCh { v.lastReports[status.ID] = status @@ -83,5 +80,10 @@ func (v *View[K]) Done(task K) { } func (v *View[K]) WaitForAllTasks() { + go func() { + defer close(v.reportCh) + v.wg.Wait() + }() + <-v.doneCh }