Welcome to weblogs.com.pk Sign in | Join | Help

One way to think of a software project is as a heavy block of stone. You must either move the block one day closer to the final destination each day, or you must do something that will enable you to traverse the remaining distance in one less day!

Whether moving a block of stone or creating computer software, the smart team takes time at the beginning of the project to plan its work so that it can work quickly and efficiently.

Smart teams continuously look for ways to work more efficiently.

Credit: Professional Software Development: Shorter Schedules, Higher Quality Products, More Successful Projects, Enhanced Careers By Steve McConnell

image

Credit:  ACM SIGSOFT Software Engineering Notes, 1989

image
Credit: ACM Software Engineering Notes, 1992

Windows Forms' (Microsoft.NET) Web Browser Control is awesome, it exposes lot of functionality to the managed code, including the ability to call JavaScript function from managed code and to call managed code from the JavaScript...Lets walk through how this can be done with a real world example, whose User Interface is shown below...

image

User clicks the "Generate" button which generates couple of graphs by hitting back-end server (over web service), this happens in BackgroundWorker and as the graphs starts generating JavaScript function is called from C# which updates the DOM showing the newly generated graph with a link "Details.." associated with each graph. Clicking this link trigger the JavaScript function which calls the C# code which generate details of clicked graph and update the HTML content in the WebBrowser Control.

To get this done, you need to decorate your Form or UserControl that is hosting the WebBrowser Control with two attributes so that your UserControl or Form get exposed to underlying WebBrowser engine (Internet Explorer which is COM based).

[PermissionSet(SecurityAction.Demand, Name = "FullTrust")]
[ComVisibleAttribute(true)]
public partial class RecentGraphsControl : UserControl
{
}
 

Then you need to set couple of properties of WebBrowser control

void RecentGraphsControl_Load(object sender, EventArgs e)
{
    this.webBrowser.ObjectForScripting = this;
    //this.webBrowser.ScriptErrorsSuppressed = true;
    //Set the above property to true if you want JavaScript errors to be ignored
}

Now to call the JavaScript function from C#

this.webBrowser.Document.InvokeScript("AppendGraphEntry", new string[] { graphName, graphUrl });

The first parameter is the name of the JavaScript function ("AppendGraphEntry" in this example) and second parameter is an array of parameters for the function

string javaScriptStringToPassBackToWebBrowser = string.Format("<img src='{1}'><a href=\"BLOCKED SCRIPTwindow.external.LoadGraphDetails('{0}')\">Details..</a><br>",
     graphName, url);

LoadGraphDetails(string graphName) is the C# public method in the RecentGraphsControl (the control hosting the browser control marked as ComVisible and whose PermissionSet is set.

Silverlight 2 is released!

Getting started

As Nasir has pointed out that Microsoft has unveiled more information about upcoming .NET Framework! I believe unlike .NET v3 and .NET v3.5 which were architecturally "addon" releases above .NET v2.... .NET v4 might be side by side release, and if it is...then i think this is great opportunity for Microsoft to simplify things a bit....

Few days ago I was talking to a PHP/Flex developer, he thinks that .NET is something that he should learn, but whenever he tried the "web.config" comes in between....he is impressed with ASP.NET MVC which appears to him the natural next choice....Ruby is Hot....if he can code some simple HelloWorld webpage with 2-5 lines of code... .NET can be very attractive....I think .NET v4 can attract large number of developers from such left overs people if....

  • The default web.config should be so that for beginners, nothing much needs to be get configured
  • IronRuby/IronPython/JScript and VBx (DLR stuff) should be the defaults..the beginners should be able to create some .aspx file and start coding in Ruby, Python, JScript or VBx straight forwardly...
  • For the Inline Coding style (which might appears more attractive to PHP developers), include some helpers in Base Class Library, with which they can get things done more straightforwardly...something as productive as Data Source Controls and Data Binding concepts for Web Forms developers...so that they feel right at home
    • Data Access Helper
    • AJAX Helper
    • Form/QueryString/Cookie Helper
    • Email Sending Helper
    • File IO/XML Helper

If you are developing some Windows Forms application, and doing some synchronous backend calls which is freezing your UI...Bring asynchronization with few lines of code using BackgroundWorker and delegates..

Consider this original code

   1:  if (null != this.smsGateway) 
   2:  { 
   3:      this.textBoxDetails.Text = string.Format("Wait downloading info for user [{0}]", subscriberName);
   4:      BigCatsDataSet ds = this.smsGateway.GetBillingInfo(subscriberName); 
   5:      if (null!=ds) 
   6:      { 
   7:          foreach (BigCatsDataSet.DataTableBillingProfilesRow user in ds.DataTableBillingProfiles) 
   8:          { 
   9:              if (user.SubscriberUserName.Equals(subscriberName)) 
  10:              { 
  11:                  if (!user.IsUplinkInKbpsNull() && !user.IsDownlinkInKbpsNull()) 
  12:                  { 
  13:                      this.comboBoxUplink.Text = user.UplinkInKbps.ToString(); 
  14:                      this.comboBoxDownlink.Text = user.DownlinkInKbps.ToString(); 
  15:                      this.textBoxDetails.Text = user.Description; 
  16:                      this.checkBoxIsCir.Checked = user.IsIsCirNull() ? false : user.IsCir;
  17:                  } 
  18:              } 
  19:          } 
  20:      } 
  21:  } 
  22:  else 
  23:      this.ErrorOccurred(this, new MvpViewArgs("this.smsGateway is not yet initialized!"));

Using Insert Code for Windows Live Writer Addin above!

this.smsGateway.GetBillingInfo() method is the one that might be freezing your UI. To make this code asynchronous, we will simply wrap this call in the BackgroundWorker's DoWork event and move the rest into its RunWorkerCompleted event. And this can be easily done using delegates...i-e no need of separate methods for these two events implementation! The issue we will hit is that as the call will happen in separate thread from where we cannt access the controls (the couple of controls being set by the returned values). This can be resolved using control' BeginInvoke method and again with delegates, its quite straightforward...

   1:  if (null != this.smsGateway)
   2:  {
   3:      string details = string.Format("Wait downloading info for user [{0}]", subscriberName);
   4:      this.textBoxDetails.Text = details;
   5:      BigCatsDataSet ds = null;
   6:   
   7:      BackgroundWorker worker = new BackgroundWorker();
   8:      worker.DoWork += delegate(object sender, DoWorkEventArgs e)
   9:      {
  10:          ds = this.smsGateway.GetBillingInfo(subscriberName);
  11:      };
  12:      worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
  13:      {
  14:          if (null != ds)
  15:          {
  16:              foreach (BigCatsDataSet.DataTableBillingProfilesRow user in ds.DataTableBillingProfiles)
  17:              {
  18:                  if (user.SubscriberUserName.Equals(subscriberName))
  19:                  {
  20:                      if (!user.IsUplinkInKbpsNull() && !user.IsDownlinkInKbpsNull())
  21:                      {
  22:                          this.BeginInvoke(new MethodInvoker(delegate()
  23:                          {
  24:                              this.comboBoxUplink.Text = user.UplinkInKbps.ToString();
  25:                              this.comboBoxDownlink.Text = user.DownlinkInKbps.ToString();
  26:                              this.textBoxDetails.Text = user.Description;
  27:                              this.checkBoxIsCir.Checked = user.IsIsCirNull() ? false : user.IsCir;
  28:                          }));
  29:                      }
  30:                  }
  31:              }
  32:          }
  33:      };
  34:      worker.RunWorkerAsync();
  35:  }
  36:  else
  37:      this.ErrorOccurred(this, new MvpViewArgs("this.smsGateway is not yet initialized!"));

You can have multiple configurations for the given Visual Studio Solution. Similarly projects in the solution can have multiple configurations, and you map them to particular solution configuration. With project's different configuration, you can setup associated tasks! For example, you have a staging and production server..you want to deploy the project(s) to staging or production server depending what configuration of the solution you are building...this is how you will do this step by step!

First create solution configuration(s)

I have unchecked creating new project configurations, as I want to create new project configuration for one (or few projects) and not all projects

Then create project configuration for particular solution configuration!

I have unchecked here the create new solution configuration option, as I already have made one

Now lets create few tasks that deploy the project items to the server, we will first unload the project so that we can edit the *.*PROJ file and then edit the project file by hand...

I am now writing the tasks that will get executed conditionally (depending on what solution/project configuration you are building)...I am calling my conditional target in afterbuild target, i-e after build is completed, my tasks will get executed (conditionally)...

I am using FtpUpload task from MSBuild Community Tasks, using which I can even upload the project items to production server's ftp location!

Once things are setup, simply choose required solution configuration and build!

 

Pushing things to staging/production servers becomes just be one build away...

I have been using Visual Studio Team System for a while now, and its really a cool set of tools to use. Brian posted about the Preview of The next TFS Power Tools few days back...Great work and thanks to Brian for keeping us updated!

I think Sharepoint has enough juice and potential as the central documentation place for development teams..and I think the integration with Sharepoint is still weak...there can be multiple scenarios where it can be further improved like...

  • Converting a SP list item to TFS Work item...so that people can discuss the requirements over the sharepoint list (forums maybe) and when it shape up, some option to convert it to TFS Work item...and TFS Work Item History gets posted back to Sharepoint so that other non TFS users can see the updates
  • Microsoft acquired TeamPlain and offered it as a free power tool, Microsoft Visual Studio Team System Web Access...Merge the The Team System Web Access with project' Sharepoint site...i-e no seperate URLs..people can logon to sharepoint project site and can manage/update work items from the same sharepoint project site!

We have a mediocre server in production where usually the scheduled job executor kind of apps get deployed...The machine is also running one Windows Service, coded in C#/.Net, developed by me. My system administrator ranged me saying that i should get it checked as machine' CPU is hitting high most of the time. Debugging (Windows) applications in production is tricky, and will need separate discussion...(and many developers and sysadmins dont have enough knowledge and know-how about getting it done in the right way). Anyways, I suggested him to use SysInternals Process Explorer (Microsoft bought SysInternals), very handy tool...and he reported back that ACE****.exe process is culprit...(which is very old third party app and it has been running fine for ages). I guessed (not yet confirmed) that due to some OS patch (or something) it has started behaving so..

I went ahead and installed ThreadMaster, an application based CPU Quota management tool...its free....runs as Windows Service and has very simple registry based settings through which you can limit CPU per application...

image

I restricted ACE****.exe to 30%, and machine started behaving just fine...

Happy Ramzan to all, especially to weblogs.com.pk readers/bloggers!!

Official Blog : http://googleblog.blogspot.com/2008/09/fresh-take-on-browser.html
The comic : http://www.google.com/googlebooks/chrome
The countdown : http://www.freechromethemes.com/DownloadGoogleChrome.php

Get your copy from http://microsoft.com/ie

  • Its blazingly fast
  • Tabs on Steriods...Tabs idea is though copied from Firefox, but they have now added atleast something new now...coloring the tab based on how your opened them...very nice
  • Looks and feels cool on Vista
  • The options it provides when you open new Tab, great job

image

Last Sunday, I spared some time to manage my eBooks folder. I tried Link Shell Extension, which helped in placing single ebook in multiple folders, avoiding copying the content...

Do not forget to read Wikipedia article on NTFS Junctions for some background information!

More Posts Next page »