<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FDevelopment_Class%2FLog</id>
		<title>Csharp/C Sharp/Development Class/Log - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FDevelopment_Class%2FLog"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Development_Class/Log&amp;action=history"/>
		<updated>2026-04-29T22:54:57Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Development_Class/Log&amp;diff=1246&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Development_Class/Log&amp;diff=1246&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Development_Class/Log&amp;diff=1247&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Development_Class/Log&amp;diff=1247&amp;oldid=prev"/>
				<updated>2010-05-26T11:45:25Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Add a EventLogTraceListener to the listener collection and writing error messages to the Application log==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// LogTrace.cs -- Demonstrates adding a EventLogTraceListener to the listener&lt;br /&gt;
//                collection and writing error messages to the Application log.&lt;br /&gt;
//&lt;br /&gt;
//                Compile this program with the following command line:&lt;br /&gt;
//                    C:&amp;gt;csc /debug:full /d:TRACE LogTrace.cs&lt;br /&gt;
using System;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
namespace nsEventLogs&lt;br /&gt;
{&lt;br /&gt;
    public class LogTrace&lt;br /&gt;
    {&lt;br /&gt;
        static public void Main ()&lt;br /&gt;
        {&lt;br /&gt;
// Create the EventLog object&lt;br /&gt;
            EventLog EvLog = new EventLog ();&lt;br /&gt;
// Register the source if it has not already been registered&lt;br /&gt;
            if (!EventLog.SourceExists (&amp;quot;AppLog.exe&amp;quot;))&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine (&amp;quot;Creating event log source&amp;quot;);&lt;br /&gt;
                EventLog.CreateEventSource (&amp;quot;AppLog.exe&amp;quot;, &amp;quot;Application&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
            EvLog.Source = &amp;quot;AppLog.exe&amp;quot;;&lt;br /&gt;
            Trace.Listeners.Add (new EventLogTraceListener (EvLog));&lt;br /&gt;
            Trace.Listeners.Add (new TextWriterTraceListener (Console.Out));&lt;br /&gt;
            Trace.WriteLine (&amp;quot;Debugging to the event log&amp;quot;);&lt;br /&gt;
// Set the source for the messages to be display in the Event Viewer&lt;br /&gt;
            EvLog.Source = &amp;quot;AppLog.exe&amp;quot;;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Demonstrates registering and event source and writing to the Application Log==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Programming Tips &amp;amp; Techniques&lt;br /&gt;
by Charles Wright, Kris Jamsa&lt;br /&gt;
Publisher: Osborne/McGraw-Hill (December 28, 2001)&lt;br /&gt;
ISBN: 0072193794&lt;br /&gt;
*/&lt;br /&gt;
// AppLog.cs -- Demonstrates registering and event source and writing to the&lt;br /&gt;
//              Application Log.&lt;br /&gt;
//&lt;br /&gt;
//              Compile this program with the following command line:&lt;br /&gt;
//                  C:&amp;gt;csc AppLog&lt;br /&gt;
using System;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
using System.IO;&lt;br /&gt;
namespace nsEventLogs&lt;br /&gt;
{&lt;br /&gt;
    public class AppLog&lt;br /&gt;
    {&lt;br /&gt;
        static public void Main ()&lt;br /&gt;
        {&lt;br /&gt;
            // Create the EventLog object&lt;br /&gt;
            EventLog EvLog = new EventLog ();&lt;br /&gt;
            &lt;br /&gt;
            // Register the source if it has not already been registered&lt;br /&gt;
            if (!EventLog.SourceExists (&amp;quot;AppLog.exe&amp;quot;))&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine (&amp;quot;Creating event log source&amp;quot;);&lt;br /&gt;
                EventLog.CreateEventSource (&amp;quot;AppLog.exe&amp;quot;, &amp;quot;Application&amp;quot;);&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            // Set the source for the messages to be display in the Event Viewer&lt;br /&gt;
            EvLog.Source = &amp;quot;AppLog.exe&amp;quot;;&lt;br /&gt;
            // Throw an exception. You don&amp;quot;t have to do this, but it&amp;quot;s a good reason to&lt;br /&gt;
            // write to the log.&lt;br /&gt;
            try&lt;br /&gt;
            {&lt;br /&gt;
                CauseTrouble ();&lt;br /&gt;
            }&lt;br /&gt;
            catch (IOException)&lt;br /&gt;
            {&lt;br /&gt;
                // Write the information to the application log&lt;br /&gt;
                EvLog.WriteEntry(&amp;quot;IO exception was thrown&amp;quot;, EventLogEntryType.Warning);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        static void CauseTrouble ()&lt;br /&gt;
        {&lt;br /&gt;
            throw (new IOException());&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Set Text Output To Event Log==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
Professional Windows GUI Programming Using C#&lt;br /&gt;
by Jay Glynn, Csaba Torok, Richard Conway, Wahid Choudhury, &lt;br /&gt;
   Zach Greenvoss, Shripad Kulkarni, Neil Whitlow&lt;br /&gt;
Publisher: Peer Information&lt;br /&gt;
ISBN: 1861007663&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.Drawing;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
using System.Windows.Forms;&lt;br /&gt;
using System.Data;&lt;br /&gt;
using System.Runtime.InteropServices;&lt;br /&gt;
using System.Threading;&lt;br /&gt;
using System.Diagnostics;&lt;br /&gt;
namespace FibersTest&lt;br /&gt;
{&lt;br /&gt;
    /// &amp;lt;summary&amp;gt;&lt;br /&gt;
    /// Summary description for Form1.&lt;br /&gt;
    /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
    /// &lt;br /&gt;
    &lt;br /&gt;
    public class fmrFibers : System.Windows.Forms.Form&lt;br /&gt;
    {&lt;br /&gt;
        private System.Windows.Forms.ListBox lstFibers;&lt;br /&gt;
        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// Required designer variable.&lt;br /&gt;
        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
        private System.ruponentModel.Container components = null;&lt;br /&gt;
        [DllImport(&amp;quot;kernel32.dll&amp;quot;)]&lt;br /&gt;
        extern static IntPtr ConvertThreadToFiber(int fiberData);&lt;br /&gt;
        [DllImport(&amp;quot;kernel32.dll&amp;quot;)]&lt;br /&gt;
        extern static IntPtr CreateFiber(int size, System.Delegate function, int handle);&lt;br /&gt;
        [DllImport(&amp;quot;kernel32.dll&amp;quot;)]&lt;br /&gt;
        extern static IntPtr SwitchToFiber(IntPtr fiberAddress);&lt;br /&gt;
        [DllImport(&amp;quot;kernel32.dll&amp;quot;)]&lt;br /&gt;
        extern static void DeleteFiber(IntPtr fiberAddress);&lt;br /&gt;
        [DllImport(&amp;quot;kernel32.dll&amp;quot;)]&lt;br /&gt;
        extern static int GetLastError();&lt;br /&gt;
        delegate void SetTextOutputToEventLog(int number);&lt;br /&gt;
        public fmrFibers()&lt;br /&gt;
        {&lt;br /&gt;
            //&lt;br /&gt;
            // Required for Windows Form Designer support&lt;br /&gt;
            //&lt;br /&gt;
            InitializeComponent();&lt;br /&gt;
            //&lt;br /&gt;
            // TODO: Add any constructor code after InitializeComponent call&lt;br /&gt;
            //&lt;br /&gt;
            Thread t1 = new Thread(new ThreadStart(NewThreadToFiberExecution));&lt;br /&gt;
            t1.Start();&lt;br /&gt;
        }&lt;br /&gt;
        void OutputLog(int fiberNumber)&lt;br /&gt;
        {&lt;br /&gt;
            this.Invoke(new AddToListBox(SetText), new object[]{fiberNumber});&lt;br /&gt;
            SwitchToFiber(obj);&lt;br /&gt;
        }&lt;br /&gt;
        void SetText(int message)&lt;br /&gt;
        {&lt;br /&gt;
            lstFibers.Items.Add(&amp;quot;Fiber &amp;quot;+message.ToString()+&amp;quot; added this&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
        delegate void AddToListBox(int message);&lt;br /&gt;
        System.IntPtr obj;&lt;br /&gt;
        void NewThreadToFiberExecution()&lt;br /&gt;
        {&lt;br /&gt;
            try&lt;br /&gt;
            {&lt;br /&gt;
                SetTextOutputToEventLog stof = new SetTextOutputToEventLog(OutputLog);&lt;br /&gt;
                obj = ConvertThreadToFiber(0);&lt;br /&gt;
                long l1 = GetLastError();&lt;br /&gt;
                System.IntPtr retVal1 = CreateFiber(500, stof, 1);&lt;br /&gt;
                System.IntPtr retVal2 = CreateFiber(500, stof, 2);&lt;br /&gt;
                System.IntPtr retVal3 = CreateFiber(500, stof, 3);&lt;br /&gt;
                System.IntPtr retVal4 = CreateFiber(500, stof, 4);&lt;br /&gt;
                System.IntPtr retVal5 = CreateFiber(500, stof, 5);&lt;br /&gt;
                if(GetLastError()!=0) throw new Exception(&amp;quot;Create Fiber failed!!&amp;quot;);&lt;br /&gt;
                IntPtr fiber1return = SwitchToFiber(retVal1);&lt;br /&gt;
                IntPtr fiber2return = SwitchToFiber(retVal2);&lt;br /&gt;
                IntPtr fiber3return = SwitchToFiber(retVal3);&lt;br /&gt;
                IntPtr fiber4return = SwitchToFiber(retVal4);&lt;br /&gt;
                IntPtr fiber5return = SwitchToFiber(retVal5);&lt;br /&gt;
                &lt;br /&gt;
                if(GetLastError()!=0) throw new Exception(&amp;quot;Create Fiber failed!!&amp;quot;);&lt;br /&gt;
                DeleteFiber(retVal1);&lt;br /&gt;
                DeleteFiber(retVal2);&lt;br /&gt;
                DeleteFiber(retVal3);&lt;br /&gt;
                DeleteFiber(retVal4);&lt;br /&gt;
                DeleteFiber(retVal5);&lt;br /&gt;
            }&lt;br /&gt;
            catch(Exception e)&lt;br /&gt;
            {&lt;br /&gt;
                throw e;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// Clean up any resources being used.&lt;br /&gt;
        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
        protected override void Dispose( bool disposing )&lt;br /&gt;
        {&lt;br /&gt;
            if( disposing )&lt;br /&gt;
            {&lt;br /&gt;
                if (components != null) &lt;br /&gt;
                {&lt;br /&gt;
                    components.Dispose();&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
            base.Dispose( disposing );&lt;br /&gt;
        }&lt;br /&gt;
        #region Windows Form Designer generated code&lt;br /&gt;
        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// Required method for Designer support - do not modify&lt;br /&gt;
        /// the contents of this method with the code editor.&lt;br /&gt;
        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
        private void InitializeComponent()&lt;br /&gt;
        {&lt;br /&gt;
            this.lstFibers = new System.Windows.Forms.ListBox();&lt;br /&gt;
            this.SuspendLayout();&lt;br /&gt;
            // &lt;br /&gt;
            // lstFibers&lt;br /&gt;
            // &lt;br /&gt;
            this.lstFibers.Name = &amp;quot;lstFibers&amp;quot;;&lt;br /&gt;
            this.lstFibers.Size = new System.Drawing.Size(320, 212);&lt;br /&gt;
            this.lstFibers.TabIndex = 0;&lt;br /&gt;
            // &lt;br /&gt;
            // fmrFibers&lt;br /&gt;
            // &lt;br /&gt;
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);&lt;br /&gt;
            this.ClientSize = new System.Drawing.Size(304, 213);&lt;br /&gt;
            this.Controls.AddRange(new System.Windows.Forms.Control[] {&lt;br /&gt;
                                                                          this.lstFibers});&lt;br /&gt;
            this.Name = &amp;quot;fmrFibers&amp;quot;;&lt;br /&gt;
            this.Text = &amp;quot;FibersTest&amp;quot;;&lt;br /&gt;
            this.ResumeLayout(false);&lt;br /&gt;
        }&lt;br /&gt;
        #endregion&lt;br /&gt;
        /// &amp;lt;summary&amp;gt;&lt;br /&gt;
        /// The main entry point for the application.&lt;br /&gt;
        /// &amp;lt;/summary&amp;gt;&lt;br /&gt;
        [STAThread]&lt;br /&gt;
        static void Main() &lt;br /&gt;
        {&lt;br /&gt;
            Application.Run(new fmrFibers());&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Test Log==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
public class TestLog&lt;br /&gt;
{&lt;br /&gt;
     public static void Main()&lt;br /&gt;
    {&lt;br /&gt;
        string logFile = &amp;quot;LOGFILE.TXT&amp;quot;;&lt;br /&gt;
        FileStream fs = new FileStream(logFile, FileMode.OpenOrCreate, FileAccess.Write);&lt;br /&gt;
        &lt;br /&gt;
        StreamWriter sw = new StreamWriter(fs);&lt;br /&gt;
        StreamReader sr = new StreamReader(fs);&lt;br /&gt;
        sw.WriteLine(&amp;quot;First log entry&amp;quot;);&lt;br /&gt;
        sw.WriteLine(&amp;quot;Second log entry&amp;quot;);&lt;br /&gt;
        while(sr.Peek() &amp;gt; -1)&lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(sr.ReadLine());&lt;br /&gt;
        }&lt;br /&gt;
        sw.Close();&lt;br /&gt;
        sr.Close();&lt;br /&gt;
        fs.Close();&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>