问题描述
按钮点击 .CS 代码
这是按钮点击,它会检查一切是否正常。将启动线程进行打印过程。
protected void btnPrint_Click(object sender,EventArgs e)
{
if (SocketPrintHelper.PingIPAddress(IPAddress,3))
{
printQueue = printing.PrintRFIDPreparation(set,int.Parse(comboPrinter.SelectedValue),int.Parse(txtQTY.Text),DataLists = new Queue<BusinessLayer.Models.PrintJob>(printQueue);
if (DataLists.Count() > 0)
{
t1 = new Thread(PrintFunction);
t1.IsBackground = true;
t1.Start();
t1.Name = "PrintThread";
lblError.Text = "Printing process is running....";
}
else
{
lblError.Text = "No record found.";
}
}
}
这是线程函数,每条记录会重试3次,如果3次失败,它会弹出radwindow询问用户是否要重试或取消进程。但是,在这个线程中添加后,radwindow 无法弹出。
private void PrintFunction()
{
try
{
if (SocketPrintHelper.PingIPAddress(printer.PrinterIP,3))
{
if (DataLists.Count() > 0)
{
foreach (var data in DataLists.Where(x => x.printed != true).OrderBy(x => x.ID))
{
byte[] byReceived = null;
bool retryFail = false;
for (int i = 1; i <= 3; i++)
{
//Do process
retryFail == true;
}
if (retryFail == true)
{
string script = "function f(){openradwindow2(); Sys.Application.remove_load(f);}Sys.Application.add_load(f);";
ScriptManager.RegisterStartupScript(Page,GetType(),"key",script,true);
break;
}
}
}
else
{
lblError.Text = "No record found.";
}
}
}
catch (Exception ex)
{
}
}
Aspx 代码
这是我的 radwindow 设计,它包含 2 个重试和取消按钮。 下面是我调用的 radwindow 函数。
<telerik:radwindow ID="confirmWindow" runat="server" VisibleTitlebar="true" VisibleStatusbar="false"
Modal="true" Behaviors="None" Height="200px" Width="280px" Font-Bold="True" OnClientShow="true" Skin="Metro" >
<ContentTemplate>
<div style="padding-left: 30px; padding-top: 20px; width: 200px; float: left;">
<div style="text-align:center;color:red" title="Print Error!">
<asp:Label ID="lblConfirm" Font-Size="17px" Text="Print/encode RFID tag 3 times fail. Do you want retry ?" runat="server"></asp:Label>
</div>
<br />
<br />
<div style="text-align:center">
<telerik:RadButton ID="RadButton1" runat="server" Text="Retry" OnClick="ClickRetry"></telerik:RadButton>
<telerik:RadButton ID="RadButton2" runat="server" Text="Cancel" OnClick="ClickContinue"></telerik:RadButton>
</div>
</div>
</ContentTemplate>
</telerik:radwindow>
function openradwindow2() {
var radwindow = $find('<%=confirmWindow.ClientID %>');
radwindow.show();
//return false;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)