c# application hang plz help
-
code is using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using RfidApiLib; using System.IO; using System.Data.SqlClient; using System.Threading; namespace Service_Ambu_Exit { public partial class Form1 : Form { RfidApi api = new RfidApi(); public int TagCnt = 0; string ip; string portNo; string p_type = ""; string p1 = ""; string arr1; int intcount = 0; public Form1() { InitializeComponent(); } private int connectReader() { try { StreamReader sr1 = new StreamReader("ipandport.txt"); string[] str2; string[] str3; string arr3; arr3 = sr1.ReadLine(); str2 = arr3.Split('='); ip = str2[1].Trim(); StreamReader sr3 = new StreamReader("ipandport.txt"); string arr2; arr2 = sr3.ReadLine(); arr2 = sr3.ReadLine(); str3 = arr2.Split('='); portNo = str3[1].Trim(); int status; int port; string s = ""; try { port = int.Parse(portNo); s = ip; } catch (Exception) { logfile("Please mention the valid ip address and port in settings file."); return 0; } status = api.TcpConnectReader(ip, port); if (status != 0) { logfile("Connect Reader Failed."); return 0; } if (ip == "172.16.100.3".Trim() || ip == "172.16.100.4".Trim()) { p1 = "STAFF".Trim(); } else if (ip == "172.16.100.5".Trim() || ip == "172.16.100.7".Trim() || ip == "172.16.100.6".Trim()) { p1 = "AMBULANCE".Trim(); } else if (ip == "172.16.100.2".Trim() || ip == "172.16.100.1".Trim()) { p1 = "BASEMENT".Trim(); } StreamReader sr = new StreamReader("RFSettings.txt"
-
code is using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using RfidApiLib; using System.IO; using System.Data.SqlClient; using System.Threading; namespace Service_Ambu_Exit { public partial class Form1 : Form { RfidApi api = new RfidApi(); public int TagCnt = 0; string ip; string portNo; string p_type = ""; string p1 = ""; string arr1; int intcount = 0; public Form1() { InitializeComponent(); } private int connectReader() { try { StreamReader sr1 = new StreamReader("ipandport.txt"); string[] str2; string[] str3; string arr3; arr3 = sr1.ReadLine(); str2 = arr3.Split('='); ip = str2[1].Trim(); StreamReader sr3 = new StreamReader("ipandport.txt"); string arr2; arr2 = sr3.ReadLine(); arr2 = sr3.ReadLine(); str3 = arr2.Split('='); portNo = str3[1].Trim(); int status; int port; string s = ""; try { port = int.Parse(portNo); s = ip; } catch (Exception) { logfile("Please mention the valid ip address and port in settings file."); return 0; } status = api.TcpConnectReader(ip, port); if (status != 0) { logfile("Connect Reader Failed."); return 0; } if (ip == "172.16.100.3".Trim() || ip == "172.16.100.4".Trim()) { p1 = "STAFF".Trim(); } else if (ip == "172.16.100.5".Trim() || ip == "172.16.100.7".Trim() || ip == "172.16.100.6".Trim()) { p1 = "AMBULANCE".Trim(); } else if (ip == "172.16.100.2".Trim() || ip == "172.16.100.1".Trim()) { p1 = "BASEMENT".Trim(); } StreamReader sr = new StreamReader("RFSettings.txt"
1. You should use <pre> or <code> tag to format code properly. 2. You should debug your application and try find the problem yourself. You just wrote some code, it doesn't work, so you think someone on the internet will fix it for you? 3. Connected to number 2 - you should tell us more specifically, what the problem is. "application hang" in the subject isn't telling us to much. You think we will run your code and check, where does it hang? We won't. Firstly you only gave us part of the code ("code-behind" of your form), and we don't know what controls you have on this form. Secondly, it's your job to locate the problem, and then we can tell you how to fix it. And if you can't locate the problem, than you should find at least a piece of code, that's causing it. Most of us here are willing to help, but you should show us, that you've done something to solve the problem yourself.
Don't forget to rate answer, that helped you. It will allow other people find their answers faster.