잊지 않겠습니다.

this is ThreadAbort Exception in Response.Redirect because of Response.End() is not completed.

 

if use Response.Redirect in try..catch block, this exception is frequent.

and this exception(System.Threading.Thread.AbortThread) is especially exception. if you catch the exception in try.. catch block, this exception is re-thrown by .NET Framework. so application programmer cannot resolve this problem.

 

So, remove System.Threading.Thread.Abort is good reason for this case.

In Response.Redirect have 2 overloaded functions.

1. Response.Redirect(string url)

2. Response.Redirect(string url, bool endResponse)

 

Response.Redirect(string url) is equal with Response.Redirect(string url, true).

if endResponse is false, Response.End() event is not occured.

Posted by Y2K
,

Seven Segment

.NET Framework 2009. 1. 7. 13:06

using System;
using System.Drawing;

namespace Chapter10_App
{
 /// <summary>
 /// SevenSegmentDisplay에 대한 요약 설명입니다.
 /// </summary>
 public class SevenSegmentDisplay
 {
  Graphics _grfx;
  static byte[,] bySegment = { {1, 1, 1, 0, 1, 1, 1},  //0
         {0, 0, 1, 0, 0, 1, 0},  //1
         {1, 0, 1, 1, 1, 0, 1},  //2
         {1, 0, 1, 1, 0, 1, 1},  //3
         {0, 1, 1, 1, 0, 1, 0},  //4
         {1, 1, 0, 1, 0, 1, 1},  //5
         {1, 1, 0, 1, 1, 1, 1},  //6
         {1, 0, 1, 0, 0, 1, 0},  //7
         {1, 1, 1, 1, 1, 1, 1},  //8
         {1, 1, 1, 1, 0, 1, 1} }; //9
  readonly Point[][] _apt = new Point[7][];
     

  public SevenSegmentDisplay(Graphics grfx)
  {
   _grfx = grfx;
   
   _apt[0] = new Point[]{new Point(3, 2), new Point(39, 2),
          new Point(31, 10), new Point(11, 10)};
   _apt[1] = new Point[]{new Point(2, 3), new Point(10, 11),
          new Point(10, 31), new Point(2, 35)};
   _apt[2] = new Point[]{new Point(40, 3), new Point(40, 35),
          new Point(32, 31), new Point(32, 11)};
   _apt[3] = new Point[]{new Point(3, 36), new Point(11, 32),
          new Point(31, 32), new Point(39, 36),
          new Point(31, 40), new Point(11, 40)};
   _apt[4] = new Point[]{new Point(2, 37), new Point(10, 41),
          new Point(10, 61), new Point(2, 69)};
   _apt[5] = new Point[]{new Point(40, 37), new Point(40, 69),
          new Point(32, 61), new Point(32, 41)};
   _apt[6] = new Point[]{new Point(11, 62), new Point(31, 62),
          new Point(39, 70), new Point(3, 70)};

  }

  public SizeF MeasureString(string str, Font font)
  {
   SizeF sizef = new SizeF(0, _grfx.DpiX * font.SizeInPoints / 72);

   for(int i = 0 ; i < str.Length ; i++)
   {
    if( (Char.IsDigit(str[i])) || (str[i] == '=>') )
    {
     sizef.Width += 42 * _grfx.DpiX * font.SizeInPoints / 72 / 72;
    }
   }

   return sizef;
  }
  
  void Fill(Point[] apt, Font font, Brush brush, float x, float y)
  {
   PointF[] aptf = new PointF[apt.Length];

   for(int i = 0 ; i < apt.Length ; i++)
   {
    aptf[i].X = x + apt[i].X * _grfx.DpiX * font.SizeInPoints / 72 / 72;
    aptf[i].Y = y + apt[i].Y * _grfx.DpiY * font.SizeInPoints / 72 / 72;
   }
   _grfx.FillPolygon(brush, aptf);
  }

  float Number(int num, Font font, Brush brush, float x, float y)
  {
   for(int i = 0 ; i < _apt.Length ; i++)
   {
    if(bySegment[num, i] == 1)
    {
     Fill(_apt[i], font, brush, x, y);
    }
   }

   return x + 42 * _grfx.DpiX * font.SizeInPoints / 72 / 72;
  }

  float Colon(Font font, Brush brush, float x, float y)
  {
   Point[][] apt = new Point[2][];

   apt[0] = new Point[]{ new Point(2, 21), new Point(6, 17),
         new Point(10, 21), new Point(6, 25)};
   apt[1] = new Point[]{ new Point(2, 51), new Point(6, 47),
         new Point(10, 51), new Point(6, 55)};

   for(int i = 0 ; i < apt.Length ; i++)
   {
    Fill(apt[i], font, brush, x, y);
   }

   return x + 12 * _grfx.DpiX * font.SizeInPoints / 72  / 72;
  }

  public void DrawString(string str, Font font, Brush brush, float x, float y)
  {
   for(int i = 0 ; i < str.Length ; i++)
   {
    if(Char.IsDigit(str[i]))
    {
     x = Number(str[i] - '0', font, brush, x, y);
    }
    else if(str[i] == '=>')
    {
     x = Colon(font, brush, x, y);
    }
   }
  }
 }
}

Posted by Y2K
,
  1. Make XmlDocument Instance
  2. CreateXmlDeclaration
  3. Create XmlNode. it is root node
  4. Create another XmlNodes. it is used childNode. these are appended childen to root node

            XmlDocument xmlDocument = new XmlDocument(); -- (1)

            XmlDeclaration xmlDeclation = xmlDocument.CreateXmlDeclaration("1.0", "UTF-8", null); -- (2)
            xmlDocument.InsertBefore(xmlDeclation, xmlDocument.DocumentElement);

            XmlElement rootNode = xmlDocument.CreateElement("SetTeamEXState Message"); --(3)
            xmlDocument.AppendChild(rootNode);

            XmlElement xmlActionNode = xmlDocument.CreateElement("Action");
            XmlAttribute targetAttribute = xmlDocument.CreateAttribute("Target");
            targetAttribute.Value = ouName;
            xmlActionNode.InnerXml = methodName;
            xmlActionNode.Attributes.Append(targetAttribute);
            rootNode.AppendChild(xmlActionNode);

            XmlElement xmlMessageNode = xmlDocument.CreateElement("Message");
            xmlMessageNode.InnerXml = message;
            rootNode.AppendChild(xmlMessageNode);

            return xmlDocument;

Posted by Y2K
,