2011年12月1日木曜日

Does the use of implicit event listener delegate for subscribing and unsubscribing to and from .NET event work?

I am pretty sure this has been discussed somewhere already on the net, but it was hard to find the answer and testing it myself was faster so here it is.

The answer is: YES, it would still correctly unsubscribe from the event.
If you run it, you will see only one line in the console output.

To demonstrate a leak, remove using() statement. You should see a second console output, indicative of an instance o Driver still hanging around in memory.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace EventTest
{
    class Program
    {
        static void Main(string[] args)
        {
            Car c = new Car();


            using (Driver d = new Driver(c))
            {
                d.DoWork();
            }


            GC.Collect();
            GC.WaitForPendingFinalizers();


            c.Start();
        }
    }


    public class Driver : IDisposable
    {
        Car _car;
        public Driver(Car car)
        {
            _car = car;
            //_car.Started += new EventHandler(car_Started);
            _car.Started += car_Started;
        }


        public void DoWork()
        {
            _car.Start();
        }


        void car_Started(object sender, EventArgs e)
        {
            Console.WriteLine("Car has started");
        }


        public void Dispose()
        {
            //_car.Started -= new EventHandler(car_Started);
            _car.Started -= car_Started;
        }
    }


    public class Car
    {
        public event EventHandler Started;


        public void Start()
        {
            if (Started != null)
            {
                Started(this, EventArgs.Empty);
            }
        }
    }
}

2011年8月16日火曜日

How to prevent Windows Server 2008 from disconnecting Remote Desktop Session when I log out

Since we migrated our server from Windows Server 2003 to Windows Server 2008, my Remote Desktop Session werer getting forcibly disconnected whenever I log out from the session. in Windows Server 2003, the programs I started during a session continue to run even after I log out from a session. Its no longer the case as the default behavior is to time out and close the programs after certain timeout.

 We need that for tesint our server process (until we turn it into Windows Services)

Here is what I had to do to keep the programs running.

First of all, run Remote Desktop Session Host Configuration




In the Connections list, select the connection, and bring up Properties.

In the Sessions tab, set the "End a disconnected session:" value to Never.


That should do it.

2011年8月12日金曜日

How to enable/install Google Analytics in DNN 6

So happy that enabling Google Analytics in DotNetNuke (DNN) was quick and easy.

I have DNN 6 installed for our game website.

Step 1: Click "+ Add new profile" button to create a new "profile" in your Google Analytics account (http://www.google.com/analytics/)




Step 2: When you get to the Tracking Code section of the profile, copy the value of "Web Property ID". It looks like UA-123456-3



Step 3: Log in to DNN as "admin" user, then click on "Google Analytics" menu item.



Step 4: Paste the ID value into the text box.




Done!

You can check back on Google Analytics profile, give it a few minutes, and it will tell you that "Tracking Status" is good to go!


Enjoy!

2011年8月2日火曜日

The first day as a full-time game company owner!

I quit the last job at DELL. It was great 2 years. Now, I am a full-timer developer of the game we have been building for so long.

I updated my LinkedIn public profile: http://www.linkedin.com/in/ywatanabe

I am going to share my experience in my new venture in this blog.

2011年3月31日木曜日

Web prototyping

Besides the core game, we will have a website that enables players to browse games, join games, launch games, invite friends, etc.

I started useing ASP.NET classic .aspx pages with .ascx controls. These are good enough for quick prototyping. The main goal is to capture user stories in either controls and pages with notes about its responsibility, the data to be shown, types of actions user can perform, etc.

This process is going to take about a week or two (or even more). However, this is worthwhile: I can show this prototype to my partner for input, test user interaction flows, identify data requirements, etc.

Trying to release the game

I have been working on a game project with my friend for about 8 years, yes I think that's about right, 8 freaking years!

We think the game is 90% complete, and we are at the "final push" to get it out of the door. Hopefully, we release it sometime this year for general public.