When using a ContentDialog in UWP to allow the user to make some kind of action that depends on a service or other asynchronous call, you probably want to ensure that call completes correctly before dismissing the dialog window. Otherwise, the result is just forgotten about. In our UWP sample app, users can give gold to a particular photo they like and leave a comment. In the GiveGoldDialog the user inputs their comment text and then presses the “ok” button, which the app then fires off actions to handle gold balance transactions and creating the comment on the photo. Before dismissing the GiveGoldDialog, we wanted to be sure that those calls completed.
When handling the PrimaryButtonClick event, before initiating the actions get a ContentDialogButtonClickDeferral object from the ContentDialogButtonClickEventArgs parameter. Creating this deferral object will prevent the button click from finishing until you complete it, suspending(or canceling) the dialog from closing until your service call finishes. Based on your service’s actions, you can even stop the dialog’s button click from closing the dialog by setting the args’ Cancel parameter to true. This could be done to tell the user that the request wasn’t able to complete and try again or that maybe their content failed some kind of validation. In our sample app we would cancel the the action if the user’s gold balance was too low to complete the transaction.
async void Dialog_PrimaryButtonClick( ContentDialog sender, ContentDialogButtonClickEventArgs args )
// Get the deferral because we need to await the
// annotation to post.
var deferral = args.GetDeferral();
// Get creation status and if failed, let's
// keep the dialog opened.
var success = await ViewModel.MakeFooServiceCall();
args.Cancel = !success;
// Complete deferral to close the dialog.
When we originally wrote this code, the deferral object wasn’t very well documented and it took us some digging to figure out what it was and how to use it. Now it seems to be well documented within an example, but maybe this post will still help someone :)
I’m a computer programmer. I mostly program with java based web technologies, but I like to try my hand in all kinds of stuff. Primarily being a web developer I can’t help but nickpick at websites when I’m browsing the web. Most of websites are designed fairly well; you can usually navigate and use it without wasting too much brain power(Facebook). Sometimes there are sites that are a bit confusing to navigate, but you can figure it out eventually(MLG). Then there are the ones that it seem like they don’t have any actual content on their page, just terribly slow fancy effects(Xerox Real Business edit//looks like they’ve updated since I wrote this, good for them!). The worst type are the sites that actually have content on them but are impossible to navigate(don’t have a current example of this, but the previous mlg website was pretty bad).
Besides considering the webpage layout/code itself, I also find myself thinking over the purpose of a website. When I create a new web application I want people to have a reason to use it and to keep using it. If they can get the same functionality somewhere else, I haven’t really accomplished anything. Some web sites don’t really try to serve a particular purpose(heynicebeard.com) while others do. I specifically want to discuss social networks here. What purpose does each one serve? How come so many people have multiple social networks? Do we really need another social network? Is it accomplishing its purpose? Who is actually using it? Well I thought I’d do a write up of sorts to name the most current most popular. Shout at me in the comments if there is one you want my thoughts on.
- Facebook has done everything right. They captured our interest by being an exclusive group(at first) and offered us order from our terrible MySpace free-for-all-layouts. Currently there is no alternative in my eyes(Google+ being the closest, more on that below) so everyone uses it and will continue to use it as they keep forcing new changes on us. Now matter how much we complain they know we aren’t going anywhere. The scariest part about facebook is that they make so much money off of us by selling our information. Facebook isn’t the product in this scheme, we are. You should always be careful what you put on the internet. Just food for thought.
- Goodreads is one of the newer social networks gaining ground. It is a network centered around sharing books with your friends. Fairly useful if you like to chat, share, and keep track of books with friends. I’ve rather enjoyed using it.
- Google+ is a fully functional social network, just without users. In many ways it is better than Facebook, and Facebook took note of them and copied those features. I use social networks to socialize with my friends but only a minuscule part of my friends use Google+, and that is why I don’t use it even though I think it is better designed.
- Linkedin is marketed as a business related network, people connect with each other and create a sort of portfolio/resume via connections, employers, and projects. However I’ve never personally encountered a use for that I actually was contacted for my job at Microsoft through Linkedin! I can imagine the connections would be useful for finding jobs through old empoyees or recommendations.
- MySpace was the first Facebook, it held the monopoly on social networking at one point. Its biggest fault was to give too much layout freedom to the users. Too many MySpace pages were slow loading, hard-to-read, multiple-music-video-playing abominations. Apparently it still survives as a more music related social network, but I don’t see how. Its slowly dying from the stigma of its own past.
- This is the newest social network I’ve encountered, and oh boy is it popular. Personally I’m not sure why its so popular. I have to give it credit since it has done a lot of things right to amp itself up–like be invite only to appear exclusive. Here is my main beef with Pinterest: it offers no functionality that you cannot already do with almost any other social networking site. What do you do? You share pictures that you have either a) upload yourself or b) get from another user. “But Kevin! Pinterest makes it so much easier!” Really? I didn’t know the share button on any Facebook link or picture was that hard to use. “But Kevin! I can have all 9000 of my pictures in my profile all sorted into their respective categories!” And do what with them? Let them sit there that is what. 95% of the pictures I see on the internet I get a good laugh and move on. 4% I might keep open in a tab on chrome to read later in the week. 1% I will save in some fashion(save on reddit, share on Facebook, or post on my blog). “But Kevin! I found a great recipe that I need to keep on Pinterest so I can cook it later!” Recipe book. Write it down. A+ for the name though. It has a ring to it.
- Tumblr is essentially a rebranded blog system. It offers nothing new except this tumblrity feature that measures how many people have reblogged your content. That’s cool I guess. If someone reblogs my stuff I would hope they credit me somehow. Again, my issue is with the network’s purpose being a duplicate of an already existing and functional social network(wordpress/blogger/any-other-blog-system). If you didn’t catch on in my Pinterest rant I am bothered when something that offers no new functionality from what we already have captivates people as something totally new. Tumblr to a lesser degree. Pinterest is basically an even more boiled down version of Tumblr. I see many people just using it as a blog and I would encourage them to use WordPress or even blogger. More freedom and cooler plugins. Also, the name is stupid.
- Reddit. Where do I begin with Reddit. I love it and I hate it. It restores my faith in humanity and makes me realize how messed up we are. I learn all sorts of interesting facts and waste hours scrolling through nothing. I can’t think of another social network where I can read endless amounts of content from nearly every single subject that interests me. One of the coolest things about Reddit is that it serves as a completely open and non-censored(apart from the illegal) content library. You can post or read almost anything. The oddest thing about reddit is how amazingly broad but eerily similar its user base is. When the hivemind is in effect Reddit looses its appeal very quickly. It is then that I become frustrated because this hivemind effectively censors that it disagrees with from being seen, which essentially goes against Reddit’s initial purpose.
- Twitter is something I see as the most misunderstood social network on the web. They either miss the point of Twitter entirely or they just don’t think technology itself is very cool and that its going to corrupt your soul if you tweet where you are ate lunch. One thing I don’t like about Twitter is that it is quickly becoming a library of idiots’ thoughts. People are either making stuff up to appear cool/funny, complaining about mundane facts of life, or trying to make their hashtag trend(OH. EMM. GEE. I just got asked if I knew how to use powerpoint. #mac4life #thingsthatartisticbarristasdealwithintheirdowntime) On the whole I find Twitter very interesting. It is one of the least structured social networks and while its only functionality is very similar to Facebook’s status updates, it serves a different purpose entirely. It initially started out asking people to answer the question “What are you doing?” but has switched its question to “What’s happening?”(Twitter’s blog post regarding the matter). A small change that had enormous impact on its purpose that I found fascinating.