Skip to content

Calling dispose twice on DisposableTimer raises a exception #798

@Rick-van-Dam

Description

@Rick-van-Dam

The problem

Calling dispose twice on DisposableTimer raises a exception. According to microsoft documentation a dispose implementation should allow this: https://learn.microsoft.com/en-us/dotnet/api/system.idisposable.dispose?redirectedfrom=MSDN&view=net-7.0#System_IDisposable_Dispose

Environment

  • NetDaemon release with the issue: JoySoftware.NetDaemon.Extensions.Scheduling 22.44.0
  • Last working NetDaemon release (if known):
  • Operating environment (Home assistant Add-on/Docker/Dev setup): Dev setup
  • Link to integration documentation on our website:

Link to or paste code that causes the issue

        var timer = new DisposableTimer(CancellationToken.None);
        timer.Dispose();
        timer.Dispose();

Traceback/Error logs

System.ObjectDisposedException: The CancellationTokenSource has been disposed.
   at System.Threading.CancellationTokenSource.Cancel()
   at NetDaemon.Extensions.Scheduler.DisposableTimer.Dispose()

Additional information

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions