• 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

    • Linux 7.2's first release candidate gets off to a good start by Paul Hill Credit: Larry Ewing It has been a few weeks since the release of Linux 7.1, and in that time, the Linux 7.2 merge window has been open, where developers can submit their features and patches ready for the upcoming release. That window is now shut, and the release candidate phase has begun so that new features can be tested and further fixes applied. According to the founder of Linux, Linus Torvalds, this week’s release candidate looks “reasonably normal”. Although we are super early in the release candidates, this is a good sign as it makes it more likely that an eighth release candidate will not be needed. Torvalds even mentioned that the update’s stats are only larger than they really are because there was another AMD header drop with a third of the patch just being AMD GPU register definitions, which aren’t big changes but make the code contributed look larger overall. In addition to this, he noted that just over half the patch is drivers, even when excluding the AMD register dump. The rest of the changes are spread out over architecture updates, tooling, documentation, and core kernel updates. In the next week, Torvalds says that he will be chilling out, taking the week “mostly off”. Despite this, he will be reading emails and keeping up with things, so if he is slow responding, now you know why. He said he is hoping for a calm week, but we will just have to see if the second release candidate is actually like that. We should expect seven or eight release candidates before Linux 7.2 is released, so expect it around the end of August. If you missed it a few weeks ago, be sure to check out our coverage of Linux 7.1's release.
    • Ridiculous claim that the labor cost difference of $6000 annually would increase cost per phone by $200. The employees produce 3 phones per month or what?
    • Sparkle 2.20.1 by Razvan Serea Sparkle is a free, open-source Windows optimization tool designed to make your PC faster, cleaner, and more private. With Sparkle, you can easily debloat Windows by removing unnecessary apps and services, disable Microsoft tracking to enhance privacy, and apply performance tweaks to boost speed. Its cleaner removes junk and temporary files, while every change is safe and fully reversible. Sparkle also features a modern, user-friendly interface with automatic updates, making system maintenance simple. Explore over 39 tweaks, from disabling telemetry and hibernation to optimizing network and game settings, all aimed at customizing and enhancing your Windows experience. Sparkle supports Windows 10 and 11. Sparkle 2.20.1 changelog: You can now change the Animation Direction from Up, Left, or Off. Added configurable animation direction (Up, Left, Off) for improved accessibility Added TTL caching to the system info backend Refactored tweak application flow to await NvidiaProfileInspector Improved IPC listener cleanup to correctly remove specific listeners Fixed online status not updating after successful network requests Updated system info tests to support backend caching Removed electron-toolkit utils dependency in favor of internal is.dev helper Fixed unwanted files and folders being included in application bundles Download: Sparkle 2.20.1 | Portable | ~100.0 MB (Open Source) Links: Sparkle Website | Github | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Never used the G7 Pro, but I've never had a good experience with that style of d-pad and fighting games.
    • And I just bought a seat cushion for my mesh chair. The chair feels nice but the first time I sat in it with boxers, I realized I don't like the feel of mesh on my legs. 😂
  • Recent Achievements

    • One Month Later
      JKR earned a badge
      One Month Later
    • Dedicated
      Asgardi earned a badge
      Dedicated
    • Conversation Starter
      jessse3334 earned a badge
      Conversation Starter
    • Reacting Well
      JuvenileDelinquent earned a badge
      Reacting Well
    • One Month Later
      Excellence2025 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      496
    2. 2
      +Edouard
      250
    3. 3
      PsYcHoKiLLa
      154
    4. 4
      Steven P.
      86
    5. 5
      macoman
      65
  • Tell a friend

    Love Neowin? Tell a friend!