Breaking News

Saturday, November 27, 2010

C#: Adding Custom Event and EventHandler

Steps to write a custom event:

Quickest way to write a custom event:

1. Write a delegate event handler
2. Write an event
3. Write a method call

public delegate void NotificationEventHandler(object sender, string Message /*Notification Message*/);
public event NotificationEventHandler NotifyEvent;

private void OnNotify(string Message)
    NotificationEventHandler handler = NotifyEvent;
    if (handler != null)
        handler(this, Message);

In any method call, whenever something happens, call it method:

OnNotify("Some important Notification Message");

You can implement the EventArgs to have your own NotificationEventArgs, that may contain type of notification, and other information.

Custom Events Using Lamba Expression:
YourObject.OnNotify += (sender,"Test") => { MessageBox.Show("This is a test");};

Or, better add that into an Extension Method.

public static void Raise(this EventHandler handler, object sender, EventArgs e)
    if(handler != null)
        handler(sender, e);

Following is how it would work, even for null events.

YourObject.Raise(this, EventArgs.Empty);

Or if you hate to check for nulls before using the events, instantiate your event with a delegate (tiny performance overhead).

public event EventHandler NotifyEvent = delegate{};
Read more ...

Saturday, November 20, 2010

Best Web Hosting Providers

The web is overwhelming with the domain registrars and hosting providers. So, which registrars should you go for and what things should you consider before you buy?

-- UPDATED -- Apr/04/2012:

Please do not "EVER" go with the Arvixe; they are the worst services providers. Day 1, I opened my account and "tried" to upload a site, Day 2: Opened a customer service ticket, Day 4: Got a reply that they "will" reply; Day 5: A reply suggesting to toggle a flag on control panel, dint work! Day 6, 7, 8, tens of conversations exchange to fix a small thing at the web server itself; Day 10: Closed my account. 3 times password reset?! can you imagine? I personally think they lack a good dedicated server administrator who has a professional degree as well. Probably thats why its cheap (0:

Anyway, a piece of unwanted advice based upon personal experience. Avoid Arvixe an sites similar to these; you can see the product feature set is attractive but it all boils down to the customer services. Worst class service.

This post is for those developers who develops for Microsoft platforms; and want to "test"-drive their dream service or product.

Usually, if you are looking for hosting on Microsoft technologies, the price is going to be higher compared to Open-Source hosting. Why? Because Microsoft servers requires licenses, and sometimes a Microsoft Certified team that takes care of Microsoft servers; hosting provider is the one that bears the cost.

Following are some types of hosting that you may want to look into before you make a decision:
Virtual private server (VPS) is a marketing term used by Internet hosting services to refer to a virtual machine for use exclusively by an individual customer of the service. The term is used to emphasize that the virtual machine, although running in software on the same physical computer as other customers' virtual machines, is functionally equivalent to a separate physical computer, is dedicated to the individual customer's needs, has the privacy of a separate physical computer, and can be configured to run as a server computer (i.e. to run server software).

Reseller hosting is a form of web hosting wherein the account owner has the ability to use his/her allotted hard drive space and bandwidth to host websites on behalf of third parties
A dedicated hosting service, dedicated server, or managed hosting service is a type of Internet hosting in which the client leases an entire server not shared with anyone.

One thing to keep in mind beyond just the price aspect is the service you get. One of the best ways to get that, is to register for the forum, where people of all trades discusses about hosting providers, domain providers, their feedback, and services - openly.

You can finalize your choices and get the community feedback for choices.

If your focus is on Microsoft .NET related technologies, then you must be looking for a provider that hosts for the same.

The primary concern for the one who is developing for windows as well start a business?

  • ASP.NET 4.0 (.NET 4.0 Framework/MVC 2)
  • Silverlight 4.0
  • MS SQL Server 2005 or 2008
  • WordPress
  • SSL
  • Payment Gateways(PayPal, Authorize.NET)
Control Panel
  • .NET Control Panel
An important point that I would emphasize is to atleast *skim* through the privacy and registration policies. Because these days everyone sells all the demographic information; and it would be nice, atleast to see, if they're being completely honest about it or not. So you might want to keep your information confidential.

If you're registering a domain for your company and you want to maintain a veil between your personal contact info and the company contact info then perhaps you should think twice about registering everything on your name.

Following is a small table that I looked into and analyzed. Based upon what I am  looking for, column 1 has the highest ratings, last column has the lowest ratings.


Pricing  USD 5/mo (72/year) USD 75/year USD 5/mo (60/year) USD 10/mo (120/year)
Disk Space Unlimited 1 GB 10 GB 10 GB
Monthly data transfer Unlimited 80 GB Unlimited Unlimited
Websites (Domains) 6 n/a Unlimited 3
Domain Name Free USD 15/year USD 12/year n/a
Uptime 99.90% 99.90% 99.90% n/a
SSL  n/a USD 10/month n/a n/a
Private Whois n/a USD 5/year n/a Free
Control Panel Dot Net n/a n/a 1AND1 Control Pnl
Remote IIS Management Yes n/a n/a n/a
Windows 2008/IIS7 Hosting No Yes n/a Yes
Windows 2003/IIS6 Hosting Faulty window server administration Yes n/a n/a
SQL Server 2008 Throws connection errors USD 10/month Yes Yes
SQL Server 2005 Yes USD 10/month Yes Yes
SQL2005 Max DB Size
300 MB 200 MB 200 MB
SQL2008 Max DB Size
500 MB 200 MB 200 MB
.NET v3.5 and above They do say they have 3.5 or above, but I think they really dont have it. For instance, I tried pushing my website using WebMatrix that itself uses v4.0, did not work Yes Yes Yes
LINQ / AJAX / Silverlight Yes, they say. You need to check this Yes Yes Yes
ASP .NET MVC Yes Yes Yes Yes
Direct Database Access(SSMS) No No Yes Yes
Streaming Audio/Video Yes Yes n/a n/a
Crystal Reports Yes No n/a n/a
Full Trust App Support n/a Yes n/a n/a
Tech Support 1 (888) 927-8493
1 (480) 505-8877

Read more ...

Tuesday, November 2, 2010

Stackoverflow is down!

Some how, worlds fastest growing questions and answers site, is down! I wonder about (t)reason. :( They recently moved their data center to NYC, which is 80 milliseconds closer Europe.

Before, while moving their data center, there was this information bar on the top of page warning about unexpected page down time, so if this would have happened then, it would have been not been a surprise. But I hope it gets up and running asap.
Read more ...

Monday, November 1, 2010

How to write simple WCF Service

Had some time, so thought of writing something for the "community", checkout How to write simple WCF Service article published on Code Project.
Read more ...
Designed By Published.. Blogger Templates