• 0

[C#][XMAL] Updating the app


Question

I am trying to build a Windows 8 metro style app using C# and XMAL is there a way to call a methord X times a second instead of when clicked , when touched est.

For example

when user hits a button X , a count down will appear on a screen , which will count down from 10 to 0.

Dont worry about getting the count down to appear just how to count down a int

int countDown;

Void UPDATE()

{

countDown --;

if (countDown == 600)

}

that type of thing.

Everything i have seen on MSDN was on button press , event stuff.

Link to comment
https://www.neowin.net/forum/topic/1131644-cxmal-updating-the-app/
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Thanks what about more advanced stuff instead of just a clock, What if i want to just say call a method from the very start and keep calling it forever?

Just like Update in XNA?

My situation im building a calculate i have a number of buttons , i want to show the current equsaion the user has imputed , just say 5 + 7 * 4 + 6.

I can call a method every time for every button , but why not something that gets called once every update. or can you do it once evey "button press".

  • 0

A couple of things:

- You'll likely want to databind the count down value to a property, and use the INotifyPropertyChanged interface to automatically reflect your back end changes to your front end view

- You'll want to maintain UI thread affinity. If you can guarantee you'll raise the initial method on the UI thread (which you can because its a button click) then it makes sense to await a Task because it captures the ambient SynchronizationContext and saves you the UI thread marshaling.

Id do something like

public async Task Countdown()
{
	   SomeCountDownProperty = 10;
	   while (SomeCountdownProperty != 0)
	   {
			  await Task.Delay(1000);
			  SomeCountDownProperty--;
	   }
}

Then on your button click event simply do:

await Countdown();

SomeCountdownProperty is a property which raises a PropertyChanged event when the value changes. It is always raised on the UI thread because the continuation is always run on the current synchronization context (which is CoreDispatcher because we are raised from a Click handler)

This topic is now closed to further replies.
  • Posts

    • I'm still rocking iOS 25.x on my primary phone cuz iOS 26 still has usability quirks (mostly aesthetic and thus its UX) which I don't wanna deal with -- and I've been piloting them with all of these updates on my backup phone, so I'm well aware of its "improvements" since iOS 26 was first released (compared to version 26.5.x).
    • Firefox 152.0.4 is out.
    • Then why are you still here?  
    • Glary Utilities 6.44.0.48 by Razvan Serea Glary Utilities offers numerous powerful and easy-to-use system tools and utilities to fix, speed up, maintain and protect your PC. Glary Utilities allow you to clean common system junk files, as well as invalid registry entries and Internet traces. You can manage and delete browser add-ons, analyze disk space usage and find duplicate files. You can also view and manage installed shell extensions, encrypt your files from unauthorized access and use, split large files into smaller manageable files and then rejoin them. Furthermore, Glary Utilities includes the options to find, fix, or remove broken Windows shortcuts, manage the programs that start at Windows startup and uninstall software. All Glary Utilities tools can be accessed through an eye-pleasing and totally simplistic interface. Glary Utilities 6.44.0.48 changelog: Optimized Context Menu Manager: Improved features based on user feedback. Optimized Wipe Free Space: Optimized the interface display for a better user experience. Minor GUI improvements. Minor bug fixes. Download: Glary Utilities 6.44.0.48 | 27.0 MB (Freeware) Download: Portable Glary Utilities | 32.3 MB View: Glary Utilities Homepage | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • Reacting Well
      Juan Dela earned a badge
      Reacting Well
    • Week One Done
      Collagen Project earned a badge
      Week One Done
    • Reacting Well
      Wakeen1966 earned a badge
      Reacting Well
    • Rookie
      Almohandis went up a rank
      Rookie
    • Apprentice
      jahara21 went up a rank
      Apprentice
  • Popular Contributors

    1. 1
      +primortal
      514
    2. 2
      +Edouard
      268
    3. 3
      PsYcHoKiLLa
      146
    4. 4
      Steven P.
      96
    5. 5
      macoman
      54
  • Tell a friend

    Love Neowin? Tell a friend!