我正在建立一个快速而肮脏的程序,基本上从我的房间打开一个灯光作为代码kata.在编程期间,我决定暂时使用winform进行测试,而不是将物理灯点亮(并在那里遇到各种可能的问题).但是当我运行我的程序winform没有显示时,我试图运行可执行文件但仍然没有.调试时我可以看到所有代码都运行正常,只是winform没有出现.这里是所有代码:
Form1.cs中:
using System;
using System.Drawing;
using System.IO;
using System.Net;
using System.Threading;
using System.Windows.Forms;
namespace alarm_light_test
{
public partial class Form1 : Form
{
WebClient client = new WebClient();
public Form1()
{
InitializeComponent();
while (true)
{
if (CheckData())
{
TurnSirenOn();
client.DownloadString("**link to .php file to reset the .txt file**");
Thread.Sleep(5000);
TurnSirenOff();
}
else
{
Thread.Sleep(1000);
}
}
}
public bool CheckData()
{
bool retval = false;
Stream stream = client.OpenRead("**link to online .txt file**");
StreamReader reader = new StreamReader(stream);
String …Run Code Online (Sandbox Code Playgroud)