David

  • About Me
  • GoGetter for Windows Phone 7
  • My Etsy Shop
  • Random
  • Archive
  • RSS
  • Ask me anything
GoGetter v1.5 is published. Should be available soon.
Pop-upView Separately

GoGetter v1.5 is published. Should be available soon.

    • #gogetter
    • #wp7
    • #wp7dev
    • #windowsphone
    • #windows phone
  • 3 days ago
  • Comments
  • Permalink
  • Share
Version 1.5 submitted! Let’s hope it passes.
Pop-upView Separately

Version 1.5 submitted! Let’s hope it passes.

    • #windows phone
    • #Windows Phone 7
    • #windowsphone
    • #WP7
    • #wp7dev
  • 1 week ago
  • Comments
  • Permalink
  • Share

Windows Phone Gray Accent Palette

I’d like to thank Paul Laberge, @plaberge, for helping me find the palette colors for the gray accent theme in Windows Phone for the lucky Nokia Lumia 800 users (UK users). I was able to create the palette colors at www.ColourLovers.com for other developers needs. Hope this can be helpful to you.

http://www.colourlovers.com/palette/1990189/WP7_Dark_Gray_Accent

http://www.colourlovers.com/palette/1990197/WP7_Lght_Gray_Accent

    • #windows phone
    • #Windows Phone 7
    • #windowsphone
    • #WP7
    • #wp7dev
  • 1 week ago
  • Comments
  • Permalink
  • Share

Mutex Snippet for Windows Phone 7

I created a little snippet for my app called “Surround with Mutex”. Basically it protects any call to the isolated storage with a Mutex.

A Mutex is: “A synchronization primitive that can also be used for interprocess synchronization.”

http://msdn.microsoft.com/en-us/library/system.threading.mutex.aspx

I had to use this due to my foreground and background agent possibly making calls at the same time to my files within isolated storage. If you do not protect your calls with a Mutex it is possible you could corrupt the data files within isolated storage. I had help with the Mutex with this bit of code example: http://www.albahari.com/threading/part2.aspx#_Mutex

I then took it for my needs and created a snippet for Visual Studio 2010. I named my snippet file Mutex.snippet. 

It is essentially just an XML document with the code below. Instead of having file named Mutex.xml it needs to be renamed to Mutex.snippet.

<?xml version=”1.0” encoding=”utf-8” ?>

<CodeSnippet Format=”1.0.0” xmlns=”http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet”>

  <Header>

    <Title>Surround with Mutex</Title>

    <Author>your name here</Author>

    <Shortcut>smutex</Shortcut>

    <Description>Surround with Mutex</Description>

    <SnippetTypes>

      <SnippetType>Expansion</SnippetType>

      <SnippetType>SurroundsWith</SnippetType>      

    </SnippetTypes>

  </Header>

  <Snippet>

    <Code Language=”CSharp”>

      <![CDATA[

                        // Naming a Mutex makes it available computer-wide. Use a name that’s

                        // unique to your company and application (e.g., include your URL).

                        using (var _mutex = new Mutex(false, “myappmutex-www.yourwebaddress.com”))

                        {

                            // Wait a few seconds if contended, in case another instance

                            // of the program is still in the process of shutting down.

                            if (!_mutex.WaitOne(TimeSpan.FromSeconds(3)))

                            {

                                return;

                            }

                            $selected$ $end$

                        }   

      ]]>

    </Code>

  </Snippet>

</CodeSnippet>

Once this file is created in your project you need to add it to your snippet library. You can do this by going to Tools->Code Snippet Manager… then clicking Import…

Then select the snippet you created “Mutex.snippet”. Once you have done this, your snippet is immediately available for use. I just select the code I would like to surround with the Mutex and press control+K, control+S then I am able to use the snippet I created. 

    • #mutex
    • #c
    • #.net
    • #csharp
    • #programming
    • #asp.net
    • #wp7
    • #wp7dev
    • #windows phone
    • #Windows Phone 7
    • #windowsphone
  • 2 weeks ago
  • Comments
  • Permalink
  • Share

Threading in C#

Great website for learning Threading in C#

    • #wp7dev
    • #wp7
    • #windowsphone
    • #windows phone
    • #windows phone
  • 3 weeks ago
  • Comments
  • Permalink
  • Share
Nokia Lumia 800 as my new emulator for Windows Phone development.
Pop-upView Separately

Nokia Lumia 800 as my new emulator for Windows Phone development.

    • #WP7
    • #wp7dev
    • #windows phone
    • #Windows Phone 7
    • #windowsphone
  • 3 weeks ago
  • Comments
  • Permalink
  • Share

Exiting a Windows Phone Application Programatically

This is just a helpful tip for those who do Windows Phone development. I had issues on trying to figure out what the best way was to exit my app from the app’s main root page. For a while I just threw an exception such as this:

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)

        {

            base.OnBackKeyPress(e);

            throw new Exception(“Exit Main”);           

        }

It irked me to do this, but it worked and passed Marketplace certification. Well, I was needing to perform some code on the App.xaml.cs level when exiting my app:

private void Application_Closing(object sender, ClosingEventArgs e)

        {

            // Do stuff here

        }

Well, this code was never called due to the exception being thrown from my main page when the back button was pressed. So, I dug in a bit to the NavigationService class and realized I could actually remove all back entries that were on the back stack. Joy! So, this is what I came up with for the OnBackKeyPress event:

protected override void OnBackKeyPress(System.ComponentModel.CancelEventArgs e)

        {

            base.OnBackKeyPress(e);

            if (NavigationService.CanGoBack)

                {

                    while (NavigationService.RemoveBackEntry() != null)

                    {

                        NavigationService.RemoveBackEntry();

                    }

                }          

        }

And voila! It worked. The app exited properly and the Application_Closing event was called from App.xaml.cs which allowed me to do some background processing of my app’s data.

Hope this can help any of you.

    • #c
    • #windowsphone
    • #windows phone
    • #Windows Phone 7
    • #silverlight
  • 3 weeks ago
  • Comments
  • Permalink
  • Share

Snippets: String to enumerated values

Useful code I use to convert string values to its enumerated counter parts.       

public static T StringToEnum<T>(string name)

        {

            return (T)Enum.Parse(typeof(T), name, false);

        }

        public static T NumToEnum<T>(int number)

        {

            return (T)Enum.ToObject(typeof(T), number);

        }

    • #c
    • #code
    • #programming
    • #snippets
    • #.net
    • #asp.net
    • #wp7
    • #windows phone
    • #Windows Phone 7
    • #windowsphone
    • #wp7dev
  • 1 month ago
  • Comments
  • Permalink
  • Share
[Flash 10 is required to watch video]
'\x3cscript type=\x22text/javascript\x22 language=\x22javascript\x22 src=\x22http://assets.tumblr.com/javascript/tumblelog.js?737\x22\x3e\x3c/script\x3e\x3cspan id=\x22video_player_16021692926\x22\x3e[\x3ca href=\x22http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\x22 target=\x22_blank\x22\x3eFlash 10\x3c/a\x3e is required to watch video]\x3c/span\x3e\x3cscript type=\x22text/javascript\x22\x3erenderVideo(\x22video_player_16021692926\x22,\'http://blog.davidarodriguez.com/video_file/16021692926/tumblr_lxyo8a2Zgj1qz8ypj\',500,375,\'orientation=landscape\\x26amp;poster=http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lxyo8a2Zgj1qz8ypj_frame1.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lxyo8a2Zgj1qz8ypj_frame2.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lxyo8a2Zgj1qz8ypj_frame3.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lxyo8a2Zgj1qz8ypj_frame4.jpg,http%3A%2F%2Fmedia.tumblr.com%2Ftumblr_lxyo8a2Zgj1qz8ypj_frame5.jpg\')\x3c/script\x3e'

Pretty cool. Lois Lane uses a Windows Phone on an episode of Smallville. Just saw this during lunch today. I had to record it. Although, I am sure I am the last to know of course.

    • #windows phone
    • #windowsphone
    • #Windows Phone 7
    • #WP7
  • 1 month ago
  • Comments
  • Permalink
  • Share

Generic agents for Windows Phone 7 (overview)

I am learning about generic agents in Windows Phone 7. I thought I would share what type of agents are available for Windows Phone.

Generic agents enables you to run custom code at regular intervals in the background of an app. There is a 1:1 ratio of an app and a generic agent. Each app has only 1 agent.

Code that needs to be run in the background lives in an agent which is a separate library (.dll file that contains the code to run in the background) that is associated with the foreground app.

The OS installs, stores, and updates the agent and foreground app together. The background agent is created and registered in the foreground app.

There are two types of scheduled tasks. That is a periodic task, and a resource intensive task that we can create in our foreground app.

Period tasks runs agent code every 30 minutes for 15 seconds. Each time the task is run the associated code gets executed in the background.

Resource intensive tasks only runs if and when the phone is in a state that power, network and processing resources are readily available (night stand mode):

  • connected to an external power instead of the battery
  • wifi is available, instead of cellular
  • the battery is at least 90% charged
  • lock screen is on
  • and there active phone call

The phone will run the task for up to 10 minutes. This will allow the phone to perform some extensive data syncing, uploading, downloading scenarios. 

The background agent can be assigned as a periodic task, resource intensive task, or both (This will allow the phone to run tasks every 30 minutes for 15 seconds and when in night stand mode, when the above conditions are met, for 10 minutes)

I will post some sample code soon.

    • #generic agents
    • #agents
    • #windows phone
    • #Windows Phone 7
    • #windowsphone
  • 1 month ago
  • Comments
  • Permalink
  • Share
← Newer • Older →
Page 1 of 3

Logo

Portrait/Logo

I created an awesome "Getting Things Done" app and I make awesome art.

GoGetter for Windows Phone 7: www.gogetterapp.com
Etsy Shop: davidrodriguez.etsy.com

Me, Elsewhere

  • @davidrodriguez on Twitter
  • Facebook Profile
  • davidarodriguez on Flickr
  • iimmerse on Last.fm
  • My Skype Info
  • Linkedin Profile

Twitter

loading tweets…

  • RSS
  • Random
  • Archive
  • Ask me anything
  • Mobile

© 2011 David A. Rodriguez. Effector Theme by Carlo Franco.

Powered by Tumblr