Device File Browsing From Desktop#

Back in March 2005 I wrote an MSDN article and part of the article dealt with copying files from the device (connected via ActiveSync) to the desktop.  I've seen a few posts in the newsgroups every so often on how this can be accomplished so I decided to create a standalone 'Device Browser' application that you can run from the desktop.

To accomplish I used the Desktop Communication Library available on the OpenNETCF website.

Here is a screen shot and the sample application can be downloaded here.

 


Tuesday, January 16, 2007 11:01:05 PM (Eastern Standard Time, UTC-05:00) #    Comments [0]  | 

 

Operator Overloading#

NOTE: This is primarly a .NET Fx Post

In a previous project I wrote a server process to do various calculations on available data.  I was given the task to see how many calculations are done per/second.  Having never done a task like this on the desktop I decided to calculate this manually using QueryPerformanceCounter, similar to something I did previously using .NET Compact Framework.  This worked and logged to a text file but it wasn't graphical,  and from my experience non-techies like seeing graphical images. 

Since it was a server process I decided to take advantage of the System Monitor and the System.Diagnostics.PerformanceCounterCategory and System.Diagnostics.PerformanceCountrer.  Since I just had to calculate the number of calculations per/second this was farily straight forward.

You setup your PerformanceCounterCategory then setup a PerformanceCounter and call Increment(). Not a big deal just a few lines of code. 

The point of the post, Operator Overloading.  During this project someone asked me how to do operator overloading in C#.  I pointed him to the MSDN documentation but actually doing something via code is better than just reading something.  The following class was created from that exercise.

/// <summary>
/// Adds overloaded operator to increment a persecond monitor
/// </summary>
public class PerformanceCounter2
{
   private PerformanceCounter perfCounter;

   public PerformanceCounter2(string categoryName, string counterName, string instanceName, bool readOnly, bool reset)
   {
      this.perfCounter = new PerformanceCounter(categoryName, counterName, instanceName, readOnly);
      if (reset)
      {
         this.perfCounter.RawValue = 0;
      }
   }
   public static PerformanceCounter2 operator +(PerformanceCounter2 perfCounter, long incrementBy)
   {
      lock (perfCounter)
      {
         perfCounter.perfCounter.IncrementBy(incrementBy);
      }
      return perfCounter;
   }
   public static PerformanceCounter2 operator ++(PerformanceCounter2 perfCounter)
   {
      lock (perfCounter)
      {
         perfCounter.perfCounter.Increment();
      }
      return perfCounter;
   }
}

Now instead of creating a PerformanceCounter you create the new PerformanceCounter2 object from the above class.  When you want to increment your performance counter, instead of calling

perfCounter.Increment();

you would call

perfCounter++;

The above class was created from an exercise to teach someone operator overloading.  It was used in production but I don't think added any real benefit.  The sample application included puts this class to use and the image below is a screen shot from using the sample application. 

PerfCounter.zip (12.56 KB)


Wednesday, March 08, 2006 4:54:41 PM (Eastern Standard Time, UTC-05:00) #    Comments [0]  | 

 

WebBrowser Control Part III#

I previously posted about the WebBrowser control in two parts.  Part one here and part two here both having to do with Windows Mobile devices.  On my current project we had a requirment to display some rich formated text so I figured why not use a browser control instead of the RichTextBox control.  On the full framework there is no 'default control' that loads up in the toolbox for web a web browser control, but if you add "shdocvw.dll" (found under Windows\System32) to your toolbox controls you get the Microsoft Web Browser ActiveX control.  Now all you have to do is drop the control in your form and you have a web browser.  Man desktop developers have it too easy!!


Friday, October 21, 2005 1:14:22 PM (Eastern Daylight Time, UTC-04:00) #    Comments [0]  | 

 

All content © 2010, Mark Arteaga
Related Sites
Archives
Sitemap
Disclaimer

Powered by: newtelligence dasBlog 1.9.7174.0

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

Send mail to the author(s) E-mail

Theme design by Jelle Druyts