gloo
gloo

Reputation: 2580

How do I include a timer in a universal windows app with c#

I need a timer in my universal windows app. I have read that the only one available for universal windows apps is System.Windows.Threading.DispatcherTimer. In order to use this I manually added the WindowsBase.dll to my app's references in the solution explorer in visual studio. Now I get the following error:

Error   3   Cannot find type System.ComponentModel.TypeConverter in module System.dll.  Game.Windows

The error goes away if I delete the WindowsBase reference. What am I doing wrong?

Upvotes: 3

Views: 3967

Answers (3)

yamspog
yamspog

Reputation: 18343

I have been using ThreadPoolTimer, in Windows.System.Threading.

Upvotes: 0

Hans Passant
Hans Passant

Reputation: 941714

The assemblies you can add to a Universal app are listed in the Project + Add Reference, Assemblies, Framework list.

Yes, it is empty.

That was intentional.

Because you already have a reference to all possible .NET assemblies in a Universal app project. Using the Browse button is not a workaround. And causes the kind of misery you describe, WindowsBase has types that can only work in a WPF app. The kind that runs with the full .NET Framework you've got installed on a desktop. Not the kind that a user has on his phone, called .NETCore. It is small, phones are small.

You already have the Windows.UI.Xaml.DispatcherTimer available in a Universal app project, no need to add a reference.

Upvotes: 4

scartag
scartag

Reputation: 17680

I think the one that windows store apps use is located in Windows.UI.Xaml namespace

Upvotes: 1

Related Questions