I want to show a message box on client side When a call is returned from service.
我想在客户端显示一个消息框当从服务返回一个调用时。
It is confirmed service runs and saves data into Database but call does not return.
确认服务运行并将数据保存到数据库中,但调用不会返回。
I Google it but did not find a way
我谷歌但没找到方法
Here is my client code
这是我的客户端代码
private void button1_Click(object sender, EventArgs e)
{
try {
string ide = txt_id.Text;
int id = int.Parse(ide);
string city = txt_city.Text;
Service1Client client = new Service1Client();
if (client.insert(id, city))
{
client.Close();
MessageBox.Show("Your changes were saved");
}
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
}
Service code
public bool insert(int id,string city)
{
Ship s = new Ship
{
order_id = id,
shipcity = city,
order_date = DateTime.Now
};
ShipsDataContext od = new ShipsDataContext();
od.Ships.InsertOnSubmit(s);
try
{
od.SubmitChanges();
Console.ReadKey();
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex);
return false;
}
}
1 个解决方案
#1
0
You are waiting for console input:
您正在等待控制台输入:
Console.ReadKey();
Btw, that error handling is a problem because you are suppressing bugs (by discarding all error information) and in case of error you do nothing.
顺便说一句,错误处理是一个问题,因为你正在抑制错误(通过丢弃所有错误信息),如果出现错误,你什么都不做。
#1
0
You are waiting for console input:
您正在等待控制台输入:
Console.ReadKey();
Btw, that error handling is a problem because you are suppressing bugs (by discarding all error information) and in case of error you do nothing.
顺便说一句,错误处理是一个问题,因为你正在抑制错误(通过丢弃所有错误信息),如果出现错误,你什么都不做。