C# code for Setting AppDomain Data

using System;
using System.Threading;

namespace AppDomainData
{
   class Program
   {
       static void Main(string[] args)
       {
           Console.WriteLine("Fetching current Domain");
           //use current AppDomain, and store some data
           AppDomain domain = System.AppDomain.CurrentDomain;
           Console.WriteLine("Setting AppDomain Data");
           string name = "MyData";
           string value = "Some data to store";
           domain.SetData(name, value);
           Console.WriteLine("Fetching Domain Data");
           Console.WriteLine("The data found for key {0} is {1}",
               name, domain.GetData(name));
           Console.ReadLine();
       }
   }
}

No comments:

Post a Comment