GlitterMonkey

sometimes you need more than just a code monkey…

WPF BackgroundWorker

Posted by glittermonkey on August 30, 2011

BackgroundWorker code snippet for fun and profit:

var worker = new BackgroundWorker();
worker.DoWork += DoStuffOnBackgroundThread;
worker.RunWorkerCompleted += StuffOnBackgroundThreadCompleted;
worker.RunWorkerAsync(spaceId);

public void DoStuffOnBackgroundThread(object sender, DoWorkEventArgs e)
{
 var sampleParameterObject = ((string)e.Argument);
 //do work here
 e.Result = myResultObject;
}

public void StuffOnBackgroundThreadCompleted(object sender, RunWorkerCompletedEventArgs e)
{
  if (e.Result != null && e.Result is MyResultType)
  {
   //do stuff with result here
  }
}

Posted in Uncategorized | Leave a Comment »

WPF Link Listing for 3-19-2010

Posted by glittermonkey on March 19, 2010

Lot’s of MIX10 related news this week.  But here are some WPF links, not related to MIX, from this week:

Posted in WPF | Tagged: | 1 Comment »

WPF Link Listing for 3-12-2010

Posted by glittermonkey on March 12, 2010

WPF Related links for 3-12-2010

Posted in WPF | Tagged: | Leave a Comment »

WPF Link Listing for 3-11-2010

Posted by glittermonkey on March 11, 2010

Below is a listing of interesting WPF links I’ve come across recently:

Posted in WPF | Tagged: | Leave a Comment »

.NET Reflection

Posted by glittermonkey on December 11, 2008

Wikipedia describes reflection as “The process by which a computer program can observe and modify its own structure and behavior.”  That’s a fairly generic definition and one that encapsulates a lot of different variations.  My understanding of reflection with respect to C# programming has always been the general idea of being able to dynamically run different chunks of code at runtime based on ‘data’.   

Meta-Information: “stores information such as the name of the contained methods, the name of the class, the name of the parent classes, and/or what the compound statement is supposed to do.  Using this information, as an object is consumed (processed), it can be reflected upon to find out the operations that it supports”

Ok, so we know that metadata or ‘meta-information’ is an important piece of the reflective programming concept.  meta-data is the ‘data’ used to make decisions about which code to run.

The following terms help me with my overall understanding of reflection and its use within the .NET framework…

Reflection: The ability to discover the overall makeup of a type (e.g. class, interface, structure, enumeration, etc.) at runtime.

Dynamic Loading: loading an assembly into memory programmatically at runtime. (think Assembly.Load or Assembly.LoadFrom)

Late Binding: The ability to create objects and invoke their members at runtime without compile time knowledge.  (think myAssembly.CreateInstance())

Attributes: Allows a developer to mark their code base with bits of custom metadata.  Attributes meaningless unless another piece of software finds and uses them via reflection

(Example real world usage – allowing a product to be extensible through the use of third-party plugins.  The extensible application defines an interface for the 3rd party plugins to implement and then these plugins can be dynamically loaded via reflection and late binding by the extensible application at runtime)

Posted in Uncategorized | Comments Off

windbg notes for quick reference

Posted by glittermonkey on October 23, 2008

attach to process

.load SOS (assumes dll is in debug tools folder)

.sympath SRV*c:\symbols*http://msdl.microsoft.com/download/symbols

debug -> break

!dumpheap -stat

!dumpheap -type Microsoft.Practices.EnterpriseLibrary.Caching

!dumpheap -mt <methodtable>   (Method Table)

!do <address>   (dump object)

!objsize <address>  (object size)

!dumpheap -stat -min 85000 (everything larget than 85000 == stuff on LOH)

!eeheap -gc  (managed heap size)

Posted in Uncategorized | Tagged: | Leave a Comment »

Configure EnterpriseLibrary Cache without app.config file

Posted by glittermonkey on August 4, 2008

The basic approach to configuring the EnterpriseLibrary Cache application block from code, without using an app.config file.

private void TestCacheConfiguration()
{
 CacheManagerFactory cacheFactory = new CacheManagerFactory(GenerateConfiguration());
 cache = cacheFactory.Create(“Sample Cache Manager”);
}

private static DictionaryConfigurationSource GenerateConfiguration()
{
 DictionaryConfigurationSource sections = new DictionaryConfigurationSource();
 sections.Add(CacheManagerSettings.SectionName, GenerateDefaultCacheManagerSettings());
 return sections;
}

private static CacheManagerSettings GenerateDefaultCacheManagerSettings()
{
 CacheManagerSettings settings = new CacheManagerSettings();
 settings.BackingStores.Add(new CacheStorageData(“inMemory”, typeof(NullBackingStore)));
 settings.CacheManagers.Add(
  new CacheManagerData(“Smart Alert Cache Manager”,
   10000,
   1000,
   100,
   ”inMemory”));
 return settings;
}

Posted in Uncategorized | Leave a Comment »

What SQL Server Edition you are running?

Posted by glittermonkey on August 4, 2008

Q.  How do you determine if you are running Standard, Enterprise, Developer, etc. edition of SQL Server?

A.  select SERVERPROPERTY(‘productversion’), SERVERPROPERTY(‘productlevel’), SERVERPROPERTY(‘Edition’)

Posted in Uncategorized | Tagged: | Leave a Comment »

No Visual Studio template information found.

Posted by glittermonkey on April 3, 2008

I started getting this error in my Visual Studio IDE today: “No Visual Studio template information found.”

 errormessage.jpg

If we take a look in the event log we see additional detail on how to address the problem:

eventlog.jpg

Open a command prompt to the location of devenv.exe and run the command: “devenv.exe /installvstemplates”

cmdprompt.jpg

We are back in business!

The only outstanding question: why did this happen in the first place?

Posted in General | Tagged: , | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.