我需要使用调度程序运行任务,问题是,如果我双击可执行文件,程序获得焦点并全屏运行,如果我使用任务调度程序运行相同的可执行文件,命令窗口仍然在顶部并且应用程序在后台运行,请有人帮帮我吗?
干杯
我正在学习Android时开发一个小应用程序.
该应用程序基本上是进行一系列简单的数学计算.按钮正在调用进行计算的函数.一切都运行正常,直到我插入一个if/else结构.
在这个构造中,我使用之前创建的变量,进行计算并使用它设置其他变量
if (TS>Ex) {
Double AE = 0.00;
} else {
Double AE = (Ex-TS);
};
Double TBTAT = (TS-Ex);
Double Exx = 2864.17;
if (TBTAT>Exx) {
Double TAT = (Exx*0.2);
} else {
Double TAT = (TBTAT*0.2);
};
Run Code Online (Sandbox Code Playgroud)
我有两个这样的if/else结构.
然后收集所有内容并发送到文本
IT_ResultTXT.setText(Double.toString(AE+TAT+TAF));
Run Code Online (Sandbox Code Playgroud)
在正常情况下,AE,TAT,TAF在代码的最后一行中变成"无法解析为变量",但如果我在函数的开头声明它们,则会出现重复变量的错误.
我想这是一个非常愚蠢的基本Java编程错误,但我无法找到解决方案.
我试图使用a SqlDataReader来运行查询,然后在消息框中显示结果,但我一直收到错误
没有数据时无效尝试读取.
这是我的代码.
public void button1_Click(object sender, EventArgs e)
{
string results = "";
using (SqlConnection cs = new SqlConnection(@"Server=100-nurex-x-001.acds.net;Database=Report;User Id=reports;Password=mypassword"))
{
cs.Open();
string query = "select stationipaddress from station where stationname = @name";
using (SqlCommand cmd = new SqlCommand(query, cs))
{
// Add the parameter and set its value --
cmd.Parameters.AddWithValue("@name", textBox1.Text);
using (SqlDataReader dr = cmd.ExecuteReader())
{
while (dr.Read())
{
label3.Text = dr.GetSqlValue(0).ToString();
results = dr.GetValue(0).ToString();
//MessageBox.Show(dr.GetValue(0).ToString());
//MessageBox.Show(results);
}
MessageBox.Show(results);
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个WPF窗口 BackgroundWorker.我在Send()这里得到一个例外:
private void worker_DoWork(object sender, DoWorkEventArgs e)
{
smtpClient.Send(mail);
}
Run Code Online (Sandbox Code Playgroud)
反过来在一个Click事件中调用某个按钮,如下所示:
private async void SendClickAsync(object sender, RoutedEventArgs e)
{
using (MessageServiceClient client = new MessageServiceClient())
{
try
{
[...]
worker.RunWorkerAsync();
}
catch (Exception ex)
{
MessageBox.Show("Error! Check your sender data!", "!", MessageBoxButton.OK, MessageBoxImage.Error);
[...]
}
}
}
Run Code Online (Sandbox Code Playgroud)
为什么不处理此异常?当我不是异步地(一切都在SendClickAsync()方法中)时,消息框弹出很好.
正如我在阅读有关GC的3本书时,我注意到一些奇怪的事实:
C#通过CLR
CriticalFinalizerObject:CLR以非常特殊的方式处理此类和从中派生的类

什么 ???
"没有找到足够的内存来编译方法? "恕我直言 - 代码应该已经编译了......不是吗?
当我编写c#代码时 - 整个代码在运行之前被编译为IL ...不是吗?但根据文本 - 在RUNTIME - 他可能发现编译的内存不足 ......
救命 ?
我正在尝试构建一个类,它将保存CSV文件中的一行数据及其标题信息.然后在课外,我正在制作这个类的元素的List <>.但是我得到的这个错误完全没用,"DynamicCSV不包含一个带有1个参数的构造函数." 事实上它实际上包含一个带有1个参数的构造函数.
class DynamicCSV : DynamicObject
{
public List<string> columnHeaders;
public List<string> rowData;
/* Constructor with 1 argument */
DynamicCSV(List<string> headers)
{
columnHeaders = new List<string>();
dynamic rowData = new List<string>();
columnHeaders = headers;
}
}
/* code that calls the constructor */
while (!streamReader.EndOfStream)
{
List<string> headers = new List<string>();
List<string> dataRow = new List<string>();
List<DynamicCSV> dataRows = new List<DynamicCSV>();
if (true == isHeaderRow)
{
currentRow = streamReader.ReadLine();
headers.AddRange(currentRow.Split(','));
dataRows.Add(new DynamicCSV(headers)); // here is the error
isHeaderRow = …Run Code Online (Sandbox Code Playgroud) 我正在尝试打开使用epplus编写的Excel文件。
我使用它打开它,它可以在开发服务器中使用,但发布后不能使用。
System.Diagnostics.Process.Start(Server.MapPath("~\chart.xlsx"))
Run Code Online (Sandbox Code Playgroud)
我该如何打开这个Excel表格?
有一种方法来检查列表框是否连接到datascource?
我的意思是这样的
if (listbox1.datascource.enabled == true)
....
Run Code Online (Sandbox Code Playgroud) 我有两个日期作为整数.如何在c#中找到这两个整数之间的月份差异?
例如:
Int32 beginDate= 20130307(yyyymmdd)
Int32 beginDate= 20140507(yyyymmdd)
Run Code Online (Sandbox Code Playgroud)
我需要14个月的结果.
我已经尝试过了:
DateTime beginDatepar = Convert.ToDateTime(beginDate);
DateTime endDatepar = Convert.ToDateTime(beginDate);
int monthDifference = ((beginDatepar.Year - endDatepar.Year) * 12) +
beginDatepar.Month - endDatepar.Month;
Run Code Online (Sandbox Code Playgroud)
但是当我将Int32转换为Datetime时,错误是"从'Int32'到'DateTime'的无效转换"
我用字符串参数创建了一个bool方法.虽然值为true,但在false时它会产生错误.在main方法中调用bool方法时,它不接受来自bool方法的相同字符串参数.
public static bool init_access(string file_path)
{
int counter = 0;
file_path = @"C:\Users\waqas\Desktop\TextFile.txt";
List<string> lines = File.ReadAllLines(file_path).ToList();
foreach (string line in lines)
{
counter++;
Console.WriteLine(counter + " " + line);
}
if (File.Exists(file_path))
{
return (true);
}
return false;
}
Run Code Online (Sandbox Code Playgroud)
如果文件确实存在,则应返回true,否则应返回false.