0

I want to do some changes here, I want to convert this application to winforms. And i want to store these output into a text file, How can I do it? please help

using System;
using System.Threading;
public static class Program
{
public static void Main()
{
     // Create a Timer object that knows to call our TimerCallback
  // method once every 2000 milliseconds.
  Timer t = new Timer(TimerCallback, null, 0, 1000);
  // Wait for the user to hit <Enter>
   Console.ReadLine();
}

private static void TimerCallback(Object o) 
{
   // Display the date/time when this method got called.
  Console.WriteLine(DateTime.Now);
  // Force a garbage collection to occur for this demo.
  GC.Collect();
 }
}

Output of this application.

enter image description here Source Stackoverflow

Community
  • 1
  • 1
newbie2222
  • 29
  • 1
  • 9
  • 1
    here's the conversoin Question: http://stackoverflow.com/questions/144701/how-do-i-convert-a-net-console-application-to-a-winforms-or-wpf-application – jbutler483 Aug 13 '14 at 13:02
  • and here's the writing to text part: http://msdn.microsoft.com/en-gb/library/8bh11f1k.aspx – jbutler483 Aug 13 '14 at 13:03
  • its not working, i want change it grammatically... – newbie2222 Aug 13 '14 at 13:04
  • 1
    BTW can I ask why you simply TOOK the code from here? http://stackoverflow.com/questions/186084/how-do-you-add-a-timer-to-a-c-sharp-console-application – jbutler483 Aug 13 '14 at 13:07
  • From amount of content in your console software, best and easiest is to create a new project and copy relevant peaces of code from old console project into new shiny winform's one. – Sinatr Aug 13 '14 at 14:14

2 Answers2

0

Go to application > and change is Application type to Winform and then point start up object at Sub Main

user3800108
  • 1,208
  • 1
  • 10
  • 14
0

Right click on the solution and select "Add Reference" Select System.Windows.Forms and hit OK

Mithil
  • 1
  • 2