控制台程序
运行后,留个10秒时间,等待输入参数, 若10秒内,没有输入,怎用默认参数,执行后续的代码 咋个写法? 谢谢
运行后,留个10秒时间,等待输入参数, 若10秒内,没有输入,怎用默认参数,执行后续的代码 咋个写法? 谢谢
解决方案 »
- 怎么在100万字的字符串文本中快速查找1000个关键字出现的次数和位置?
- 关于GUI的Listbox和TextBox在定时状态都不能及时更新内容的疑问
- C#在本机创建QQ或飞信机器人,根据内容自动回复收到的消息
- datagridview 排序问题?
- 异步非阻塞socket
- 关于库结构
- Console.In.ReadLine()等待问题
- 如何在asp.net里画组织机构图
- 【求教】经验公式为Qg=a*X^b,如何根据实测值回归得到a,b?
- 求解 C# 登陆UNIX在shell下执行shell命令
- C#如何监听或者说是截获本机的网络请求和响应
- c# FileSystemWatcher 应用的一个问题
static void Main(string[] args)
{
string input = "my default";
Task.Factory.StartNew(() => { input = Console.ReadLine(); }).Wait(10 * 1000);
Console.WriteLine(input);
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using System.Windows.Forms;namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string s = "";
bool inputted = false;
System.Threading.Timer t = new System.Threading.Timer(new TimerCallback(o => { if (!inputted) SendKeys.SendWait("{enter}"); }), null, 10 * 1000, 0);
s = Console.ReadLine();
inputted = true;
Console.WriteLine(s);
}
}
}添加引用 System.Windows.Forms