Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more APIs to IDispatcher #4944

Merged
merged 5 commits into from
Feb 28, 2022
Merged

Add more APIs to IDispatcher #4944

merged 5 commits into from
Feb 28, 2022

Conversation

mattleibow
Copy link
Member

@mattleibow mattleibow commented Feb 26, 2022

Description of Change

Part of #1965
Fixes #3950

This PR copies the API of Windows as that is fairly nice, and adds 2 new APIs:

public interface IDispatcher
{
+	bool DispatchDelayed(TimeSpan delay, Action action);
+	IDispatcherTimer CreateTimer();
}

+public interface IDispatcherTimer
+{
+	TimeSpan Interval { get; set; }
+	bool IsRepeating { get; set; }
+	bool IsRunning { get; }
+	event EventHandler Tick;
+	void Start();
+	void Stop();
+}

We now have a few ways to do timer-y things in Maui:

  • System Timer objects
    These timer objects are using whatever the BCL uses to implement it. This may/may not sync with UI updates and things.
  • Animations
    This is the logic used by our animations API, and is directly tied to the screen refresh rate. This is using the CADisplayLink and similar on other platforms.
  • Dispatcher CreateTimer
    This is the new API and is a timer based on the dispatcher availability and frequency.

In order to chose which one to use, there are some simple rules:

  • If you want to trigger some event in some work with relative accuracy, use the system/BCL timers
  • If you want to have something that directly syncs to the screen refresh rate, use the animation APIs
  • If you want to queue something on the UI thread repeatedly, use the dispatcher timers

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)
  • Targets a single property for a single control (or intertwined few properties)
  • Adds the property to the appropriate interface
  • Avoids any changes not essential to the handler property
  • Adds the mapping to the PropertyMapper in the handler
  • Adds the mapping method to the WinUI, Android, iOS, and Standard aspects of the handler
  • Implements the actual property updates (usually in extension methods in the Platform section of Core)
  • Tags ported renderer methods with [PortHandler]
  • Adds an example of the property to the sample project (MainPage)
  • Adds the property to the stub class
  • Implements basic property tests in DeviceTests

Does this PR touch anything that might affect accessibility?

  • Does this PR introduce a new control? (If yes, add an example using SemanticProperties to the SemanticsPage)
  • APIs that modify focusability?
  • APIs that modify any text property on a control?
  • Does this PR modify view nesting or view arrangement in anyway?
  • Is there the smallest possibility that your PR will change accessibility?
  • I'm not sure, please help me

If any of the above checkboxes apply to your PR, then the PR will need to provide testing to demonstrate that accessibility still works.

* Delayed
* Timer
@mattleibow mattleibow self-assigned this Feb 26, 2022
@mattleibow mattleibow marked this pull request as draft February 26, 2022 11:55
@mattleibow mattleibow added area-animation Animation, Transitions, Transforms Cost:M Work that requires one engineer up to 2 weeks p/0 Work that we can't release without t/enhancement ☀️ New feature or request Status:InProgress and removed p/0 Work that we can't release without Cost:M Work that requires one engineer up to 2 weeks labels Feb 26, 2022
@mattleibow mattleibow marked this pull request as ready for review February 27, 2022 17:45
@mattleibow mattleibow added this to the 6.0.300-preview.14 milestone Feb 27, 2022
@Redth Redth merged commit a1ed3b6 into main Feb 28, 2022
@Redth Redth deleted the dev/start-timer branch February 28, 2022 17:30
@github-actions github-actions bot locked and limited conversation to collaborators Dec 23, 2023
@samhouts samhouts added the fixed-in-6.0.200-preview.14.2 Look for this fix in 6.0.200-preview.14.2! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-animation Animation, Transitions, Transforms Cost:M Work that requires one engineer up to 2 weeks fixed-in-6.0.200-preview.14.2 Look for this fix in 6.0.200-preview.14.2! p/0 Work that we can't release without Status:InProgress t/enhancement ☀️ New feature or request
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

StartTimer - remove
3 participants