473,320 Members | 1,948 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

None of the buttons is working

When i start the program, it simply freezes. I mean if i push any button, it doesn't work. Only button10 is working which is closing the form.
What is the problem here?

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
//using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Threading;


namespace Samp_cpanel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
Process p = new Process();
new bool running = false;
new bool loaded = false;

private void button1_Click(object sender, EventArgs e)
{
if (running == true)
{
MessageBox.Show("Server already running!", "Error!");
}
else
{
p.StartInfo.FileName = "samp-server.exe";
p.Start();
running = true;
Thread.Sleep(200);
Query.Query sQuery = new Query.Query("76.10.223.139", 7777);
sQuery.Send('i');

int count = sQuery.Recieve();

string[] info = sQuery.Store(count);
if (info.Length == 0)
{
hostname.Text = "The server is DOWN!";
}
else
{
Query.Query dQuery = new Query.Query("76.10.223.139", 7777);
dQuery.Send('c');

int c2 = dQuery.Recieve();
string[] pl = dQuery.Store(c2);
for (int i = 0; i < Convert.ToInt64(info[1])*2; i++)
{
ListViewItem lvi = new ListViewItem(pl[i]);
lvi.SubItems.Add(pl[i + 1]);
listView1.Items.Add(lvi);
i++;
}

hostname.Text = info[3];
players.Text = info[1] + " / " + info[2];
mapname.Text = info[5];
gmtext.Text = info[4];
}
}
}

private void button2_Click(object sender, EventArgs e)
{
try
{
p.Kill();
running = false;
}
catch { }
}

private void Form1_Load(object sender, EventArgs e)
{
}

private void button3_Click(object sender, EventArgs e)
{
try
{
p.Kill();
p.Start();
}
catch { }
}

private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = File.ReadAllText("server.cfg");
loaded = true;
}

private void button4_Click(object sender, EventArgs e)
{
if (loaded == false)
{
MessageBox.Show("You must load the cfg file", "Error!");
}
else
{
File.WriteAllText("server.cfg", textBox1.Text);
MessageBox.Show("The cfg file was totally edited", "Success!");
}
}
private void button6_Click(object sender, EventArgs e)
{
Query.RCONQuery jQuery = new Query.RCONQuery(textBox5.Text, Convert.ToInt16(textBox6.Text), textBox7.Text);
if (textBox2.Text == "")
{
if (textBox3.Text == "")
{
if (textBox4.Text == "")
{
}
else
{
jQuery.Send("mapname " + textBox4.Text);
}
}
else
{
jQuery.Send("gamemodetext " + textBox3.Text);
}
}
else
{
jQuery.Send("hostname " + textBox2.Text);
}

}

private void textBox6_TextChanged(object sender, EventArgs e)
{

}

private void button7_Click(object sender, EventArgs e)
{
Query.Query cQuery = new Query.Query("127.0.0.1", 7777);
cQuery.Send('i');

int count = cQuery.Recieve();

string[] info = cQuery.Store(count);
if (info.Length == 0)
{
hostname.Text = "Serverul este DOWN!";
players.Text = "";
mapname.Text = "";
gmtext.Text = "";
}
else
{
hostname.Text = info[3];
players.Text = info[1] + " / " + info[2];
mapname.Text = info[5];
gmtext.Text = info[4];
}
}


private void button10_Click(object sender, EventArgs e)
{
this.Close();
}

private void groupBox1_Enter(object sender, EventArgs e)
{
}


}
}
Dec 13 '11 #1
2 1490
GaryTexmo
1,501 Expert 1GB
If nothing happens when you push the buttons, two things are possible...

1) The event handlers didn't connect. An easy check is to put a message box call as the first line in an event handler, or a Console.WriteLine message, and see if that happens. Alternatively you could set a breakpoint. If the event handler isn't being called, ensure it's actually attached to the event. If you did it through the designer this would be in the _____.designer.cs file for your form.

2) If you do the above and your event is working, then it's likely your code doesn't work properly. I took a quick look and this looks like it's your own stuff so I can't really help you very much. Debug it using breakpoints and output statements and try to figure out what's not working.
Dec 13 '11 #2
arie
64
I think it is probable that your comunication with the server causes this. Does the methods you use (Send/Receive) are blocking or unblocking? If it's the former, then the situation you described can happen (I mean, the GUI will freeze until the response is received). To avoid it, you can e.g. use BackroundWorker.
Dec 14 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Matt L. | last post by:
Does anyone know why the onmouseout isn't working in the following? I've just started the script (tho I'm sure I've spent over 40hrs on this problem alone) and am trying to get just 2 buttons...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
6
by: AJBopp | last post by:
I'm wrestling with CSS variations between Firefox and IE. I'm trying to create rollover buttons in a menu frame. It is working perfectly in Firefox but in IE only the first button is properly...
2
by: tradmusic.com | last post by:
Hi. Trying to create a roll-over button effect using CSS and it's working great in Firefox: http://www.nathonjones.com/sitc/salmon.shtml However, it looks totally different in IE. The first...
15
by: cssExp | last post by:
hello, Rather than going on a wild explanation on what's the the problem, it'll be much quicker and easier if i let you look at it yourself, so I'll post my page source (actual contents taken out,...
10
by: Lindsay Browning | last post by:
Hello, I found a previous posting by someone on the 10th Sept (http://www.thescripts.com/forum/thread705528.html) who seemed to have the same problem as me, but it was never resolved. I have...
2
by: GloStix | last post by:
For some reason, FF likes to put a black underline on all my buttons. No matter what I do, it has the line I've tried displaying as block and cursor, anything.. Also I've been trying to get it so...
8
by: GaryDean | last post by:
I have a Wizard page and need to affect the next and previous buttons from my code-behind. I've googled around and found two solutions, and neither appear to work. I can access the SideBarList...
3
by: crs27 | last post by:
Hi, I Have the below declaration of an array var latitude = ; which is working in IE but the same is not working in Mozilla. i changed it to var latitude = new Array() ; var latitude = new...
0
by: Utku | last post by:
Is it possible to add "select all" and "select none" buttons to MultiChoiceDialog in wxPython?
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.