WP8 Create a second tile causing App exit - windows-phone-8

To add a second Flip tile, I use the following code at the first time loading of MainPage.xaml
if the tile doesn't exist, then....
ShellTileData tileData = this.CreateFlipTileData(idx);
ShellTile.Create(tileUri, tileData, true);
The tile is created successfully, but the issue is the App will exit, of course, if user start the app again, it will be fine. Just wondering it is not a good experience, is there a better way.

There is no way to stop the your app from exiting when a new secondary tile is created. The best thing to do is be prepared for when the user presses the Back button to step backwards into your app.
Also, it's good to note that updating an existing tile will NOT cause the app to exit, only the creation of new tiles.

Related

Game Maker studio: When I run the game

After I loaded the game up I get this error message below
I loaded the game back up and though it worked again because my slime enemy are still moving around the game but when I left clicked the mouse, my game just freezes and I have to end up exiting out the game.
I went to game maker community website page and see others with the same issue as I did, but most people said it's something with game maker studio's file > preferences and on the window's tab I see the location.
I pressed check windows SDK button and though it worked because I see status shows Visual studio is OK. I though that worked any ideas?
// In Script scr_check_for_player at line 1 : unknown function or script instance_exist
// In Script scr_enemy_choose_next_state at line 3 : wrong number of arguments for function irandom
// In Script scr_enemy_choose_next_state at line 3 : malformed assignment statement
// Compile Failed - Please check the Compile window for any additional information
To the best of my knowledge, the game maker function instance_exist is actually instance_exists, try that and see if it is correct. Also, search for the arguments in the function irandom and apply it correctly.

List box is not updating in Windows Phone 8

I am developing one application, in that I have 3 pages. In first page I have List Box with some data and in 3rd page I have application bar for navigating to first page. I will get the list box data from the server. Whenever I am binding the List Box with server data, it is rendering properly but if the user navigate from 3rd page to 1st page using application bar then List box is not updating with fresh data, it is still displaying old data. If user comes to first page using back key press then new data is rendering.
I am using observable collection to bind List Box data and used NavigationService.Naviagte() for navigation.
Help me to resolve this issue.
Thanks in advance.
I am not very sure about your problem because you haven't cleared the whole context. But assuming that your data is refreshing on back key press, I can suggest you use NavigationService.GoBack() instead of NavigationService.Naviagte(). The former method call is equivalent to back key press. NavigationService.Naviagte() creates another instance of the page in the memory while NavigationService.GoBack() takes you back to the previous instance. Hope this helps.
As I understand everything is fine when you start. But the update is not happening upon second return, i.e. Through navigation.
My thought is that all your code to do this is in the constructor, and since the page is not removed from memory the constructor will not be called.
Two solutions move the code to a loaded event. Simply in the constructor write this.loaded += eventname;
Or you could put code in the onnavigatedto event. Write as a new function protected override onnavigatedto.
Putting it in the navigatedto, would probably make your app less responsive if you do server calls. If you have the code in the loaded event then the information will be uploaded when it is done. Which means the user will have a moment with old information. You could then introduce a waiting screen if it is an issue.

How to check if UiInstance is running?

How to check if a UiInstance is already running? I need to know so that I know whether to use UiApp.getActiveApplication() or UiApp.createApplication(); The issue is that the functions may not be called in a particular order.
No offense but this question doesn't make a lot of sense to me... There can be only one UiApp instance and in a standalone app it must start with a doGet() so I wonder how you could start an app without starting by the app creation ?
Once you have created this instance it lives as long as you close your browser window of you hide all the possible source of user actions (for example hiding all the widgets or disabling all the buttons) and everything that happens in between is either the result of a handler call or a direct function call in the script, all of which are necessarily subsequent and therefor using getActiveApplication().
If I missed something (which is entirely possible of course) please explain.
Edit : following your comment :
In case you use UiApp embedded in a document the situation is a bit different but not so much :
2 different cases :
Dialogs :each time you create a new one it will appear "over" the existing one but won't be "aware" of it, i.e none of the first UI values will be available to the next one. So it's a better idea to close each one before creating a new one (app.close();return app;) otherwise you'll have to manually close each "layer" successively since I guess it wouldn't be a good idea to keep the dialog on the screen all along :-)
Data passing from one instance to the other must be handled using some kind of storage.
Sidebar : what I'd suggest is to create a starting UI in the sidebar that creates the Ui (showing a welcome message or a menu for example) and let all the other function get this Ui Instance using getActiveApplication() , that will avoid the UI "flashing" while it's been redrawn and allow you to play with all the values all along.
In both case the choice is really yours but the practice I suggest works better and gives you full control on what happens.

MS Access On_Current event not firing on very first run of the application

I have an MS Access front end application in which the first form to be opened (a splash screen - the form is opened from the Autoexec Macro) has an on_Load event which sets the timer interval to 0, and an on current event which sets it to 100. The timer event starts the application running (attaching to the backend SQL Server Database etc).
When a fresh copy of the application is copied to a new place - we do that when there is a new release - it gets copied to each users machine, the very first call of the application acts as through the timer never fires. In other words it appears the the on current event never fires.
I cannot find what is causing it, and my only explanation that I can think of is that in testing the start up just before release, I have set the form so its current record IS the one that is set when the form loads on start up.
Is this true? Is there a situation anyone is aware of where the on_current event doesn't fire for that, or any other reason.
The reason I wait until the on_current event is that the form itself has a data-source which depending on the form filter sets the parameters for different databases to connect to (production v test for instance). A work around may be to set the timer interval in the on load event - but it opens up to a possible race condition where the timer fires before on_current has set the correct database, and I would prefer to avoid that risk
On Current fires when you move to a new record. To force it to fire, you might try to move to the last record, then back to the first.

Design Pattern to require multiple events before executing method?

There are many times that I've needed to execute some code after a number of events have fired, and I've come up with counters and such but I feel there must be a better way.
For example, say five files need to be loaded, after which a UI component will become active.
If I set up a counter that increments each time a file is requested, then decrements each time one has loaded, I run the risk that the first two or three files may somehow get completely loaded before my code gets around to requesting the fourth and fifth, which would mean that my counter would be at zero when I still have two files to load, thus allowing the UI component to be prematurely activated.
There are some cases where you could know the number that need to be loaded before the requests go out, but it's possible that the first file contains the paths (and therefore the number of) files. (And this file-loading scenario is only an example of the pattern I'm trying to explain.)
Does anyone have an elegant solution for this? (Does my description make sense?) Thanks!
You could do something with a task framework like spicelib
Using that as an example
Create a FileRecursionLoadTask which grabs a file and completes when that file and any references it makes are loaded.
Add each FileRecursionLoadTask to a SequentialTaskGroup.
When the TaskGroup is completed, then you know all of the file loads have completed.
There are also plenty of other task frameworks which you might like better. For example, Spring ActionScript also has one.
Before executing a request, store a reference (a unique request uri, the loader object or a special command object) in a list. When a loader has finished, remove that object and call a function that checks if there are remaining active tasks in the list.
This isn't specific to file requests nor request in general, it can be used for anything that needs to wait for multiple actions to finish. Multiple list can be used to process multiple types of action at the same time. The object stored in the list could be implemented as a command object, which could provide more information about the task. This is called command pattern.
If you're doing just loading, like Jacob, I would also suggest a library that handles loading
If the case of a more complicated situation like mixing loaders and other event listeners, I would suggest using an event that fires whenever there is any change to any of the dependencies. In addition all the objects/classes would have a state.
Then I would create a listener adding function for the class that would need to do the function or initiate it, that would have 3 parameters
object with event dispatcher (assuming they all use the same update event) ie. assetLoader
name of object state ie. headerLoaded
state value's desired ie. true
the function would add the listener to a chain of listeners, and any time any of the listeners fires, all objects would check if the state value.
This would allow for regression as well (like when a user presses a button, the content starts loading, but then the user presses cancel, even if all the assets load, the state of one object would be false, thus not allowing the item to complete) If you were using counters, it would be the equivalent to adding instead of subtracting, but much more reliable.
Looking for a design pattern? Try the command pattern (http://johnlindquist.com/2010/09/09/patterncraft-command-pattern/)
(The video is a great example of what command pattern is and how it works - using Starcraft as an example.
The implementation is that you queue your load commands so that they do not execute out of order, and you can add the enable or disable commands to your command que. So the command pattern will play back your commands something like: load, load, load, enable ui item, load, load, enable another item
Good luck