|
squerley wrote: i cant see the ReadInPeople method in my main form unless i use public instead of privete and if i use public i get an exception...
will you mention exception which is occur?
|
|
|
|
|
What are you trying, please be clear. Fistly your question is you are not getting all lines or something other
|
|
|
|
|
|
Hi,
I have this code which works fine but there is a major issue specially i am going t run this on the server! when the code in the timer start running, the CPU usage of the machine jumps from 16% to 78%? of course after completed it will go back to normal but my question. what's happening in the code? why it take this much from CPU?
MySqlConnection sql_connection = null;
MySqlCommand sql_command = null;
MySqlDataAdapter sql_adapter;
DataTable data_table = null;
MySqlDataReader sql_reader = null;
DataSet data_set = null;
public public_class public_var = new public_class();
const int MF_BYPOSITION = 0x400;
[DllImport("User32.dll")]
private static extern int RemoveMenu(IntPtr hMenu, int nPosition, int wFlagS);
[DllImport("User32.dll")]
private static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);
[DllImport("User32.dll")]
private static extern int GetMenuItemCount(IntPtr hWnd);
public delegate void ControlStringConsumer(Control control, string text);
public int result_rows;
public frmMain()
{
InitializeComponent();
}
public void SetText(Control control, string text)
{
control.Invoke(new ControlStringConsumer(SetTextGUI), new object[] { control, text });
}
public void SetTextGUI(Control control, string text)
{
control.Text = text;
}
private void perform()
{
get_statistics_summary();
send_sms();
}
private void get_statistics_summary()
{
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_connection.Open();
sql_command = new MySqlCommand("SELECT COUNT(*) AS total_files FROM persons", sql_connection);
sql_command.CommandType = CommandType.Text;
sql_reader = sql_command.ExecuteReader();
if (sql_reader.Read())
{
SetText(lblTotalFiles, sql_reader["total_files"].ToString());
}
sql_reader.Close();
sql_command = new MySqlCommand("SELECT COUNT(*) AS total_appointments FROM appointments", sql_connection);
sql_command.CommandType = CommandType.Text;
sql_reader = sql_command.ExecuteReader();
if (sql_reader.Read())
{
SetText(lblTotalAppointments, sql_reader["total_appointments"].ToString());
}
}
private void send_sms()
{
sql_connection = new MySqlConnection(ConfigurationManager.ConnectionStrings["SQLdb"].ConnectionString);
sql_connection.Open();
sql_command = new MySqlCommand("sp_send_pending_sms", sql_connection);
sql_command.CommandType = CommandType.StoredProcedure;
sql_reader = sql_command.ExecuteReader();
while (sql_reader.Read())
{
SetText(lblTimer, sql_reader["sms_queue_id"].ToString());
}
}
private void frmMain_Load(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
IntPtr hMenu = GetSystemMenu(this.Handle, false);
int menuItemCount = GetMenuItemCount(hMenu);
RemoveMenu(hMenu, menuItemCount - 1, MF_BYPOSITION);
timerMain.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["ServerTimerInterval"]);
}
private void btnEmailTemplates_Click(object sender, EventArgs e)
{
frmEmailTemplates EmailTemplatesForm = new frmEmailTemplates(public_var);
EmailTemplatesForm.ShowDialog();
}
private void frmMain_Shown(object sender, EventArgs e)
{
this.Cursor = Cursors.WaitCursor;
timerMain.Start();
this.Cursor = Cursors.Default;
}
private void timerMain_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
backgroundWorkerSMS.RunWorkerAsync();
}
private void btnOptions_Click(object sender, EventArgs e)
{
frmOptions OptionsForm = new frmOptions();
DialogResult options_form = OptionsForm.ShowDialog();
if (options_form == DialogResult.OK)
{
timerMain.Stop();
timerMain.Interval = Convert.ToInt32(ConfigurationManager.AppSettings["ServerTimerInterval"]);
timerMain.Start();
}
}
private void backgroundWorkerSMS_DoWork(object sender, DoWorkEventArgs e)
{
perform();
}
private void backgroundWorkerSMS_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
backgroundWorkerSMS.Dispose();
}
</pre>
|
|
|
|
|
is your code and the database running on the same machine?
how many cores are there?
what is inside the stored procedure?
how many different values are you sending to lblTimer per second? (or how long is the SMS table and how long does your code actually run?
if you don't have polling loops, and if you have chosen good algorithms, CPU activity is OK, it just says the processor is working for you.
if the database is elsewhere or the SP is light, then your code is mostly switching threads to update some labels, i.e. your GUI is costing a lot then.
[ADDED]
1. you're not going to have a display with a permanent status update on a server, are you?
2. when update frequency is high, a better approach is to store, not display, the status in some variable(s), and have the GUI update itself (with a Windows.Forms.Timer) a few times a second. When the variable is a 4-byte int or smaller, no need to have synchronization logic (such as locks) at all.
[/ADDED]
|
|
|
|
|
s your code and the database running on the same machine?
Yes both on the same machine.
how many cores are there?
Core Due
what is inside the stored procedure?
Just a select statement only
how many different values are you sending to lblTimer per second? (or how long is the SMS table and how long does your code actually run?
The code runs for about 10seconds
|
|
|
|
|
jrahma wrote: The code runs for about 10second
and how many SMS (and hence lblTimer updates) is that?
|
|
|
|
|
Is the CPU being used by your application or the SQL Server?
|
|
|
|
|
What is your timer interval set to? If it is too small, they tick events may be happening too often depending on the time it takes to perform the actions in each one.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
and how many SMS (and hence lblTimer updates) is that?
I am not sending anything now because I am just testing but I am looping through about 100records only
Is the CPU being used by your application or the SQL Server?
I am using MySQL not Sql Server
What is your timer interval set to?
It's set to 15minutes but even if I set to 24hours CPU will jump to 78% from the time the timer runs
|
|
|
|
|
please give me idea about effect. in android or windows vista a effect is used when any application window is open or closed. effect is like grow and shrink. very similar like jquery transfer effect. i can generate that effect like window size increment or decrement with in time but it flicker and not smooth like professional. so please guide how to generate that effect in windows application which look very professional. also tell me is there any free open source library to generate that kind of effect. please me with sample code.
thanks
tbhattacharjee
|
|
|
|
|
Is that what your users want? I wouldn't.
|
|
|
|
|
no rather i want to design in such way for users eye's satisfaction. can u help me.
tbhattacharjee
|
|
|
|
|
Why don't you just concentrate on creating a well design/well written application. These bells and whistles are a waste of time.
|
|
|
|
|
Hello:
i use vs2005(C#) and the OS is WinXP.
Now i want to get the local pc's monitor's status,
include [on] [off] [standby] three status.
what should i do.....
Thanks
|
|
|
|
|
|
|
Ask the user to click a button.
|
|
|
|
|
Accurate? Yes.
Helpfull? No.
Have a five anyway!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I think he used to be an editor at MSDN...
Will Rogers never met me.
|
|
|
|
|
Excel receive live data from DDE .How to retrieve those values.I must read unsaved live data
|
|
|
|
|
Error 1 Unsafe code may only appear if compiling with /unsafe C:\Visual Studio 2010\Projects\Unsafe\Unsafe\Program.cs 6 24 Unsafe
Error 2 Unsafe code may only appear if compiling with /unsafe C:\Visual Studio 2010\Projects\Unsafe\Unsafe\Program.cs 10 31 Unsafe
using System;
class Unsafe
{
unsafe static void SquarePtrParam(int *p)
{
*p *= *p;
}
unsafe public static void Main(string[] args)
{
int i = 5;
SquarePtrParam(&i);
Console.WriteLine(i);
}
}
How to run csc /unsafe *.cs
|
|
|
|
|
if running SCS from the command line, add the switch.
if running Visual Studio, go to Project Properties, and look for "Allow unsafe code" checkbox.
|
|
|
|
|
Deja Vu all over again. The 3rd time this user has asked the same question
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Just found some of his attempts to ask this, earliest one dates August 10[^]!
|
|
|
|