|
Managed memory doesn't get fragmented, as the garbage collector compacts the heap. If your application really leaks memory, it's unmanaged memory. Are you disposing all objects that needs disposing?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa,
I use an external C++ library (QuickFix), so I would imagine that's where unmanaged memory is used. Otherwise, everything in my code is managed C#. I thought maybe in some momemnt of lunacy I did write unmanaged code, but search for words "unsafe" or "~" or "!" produces nothing.
When you say "application really leaks memory", wouldn't it cause increase in the Private Bytes memory? I don't observe that. The Private Bytes are increasing throughout the day, but every couple of hours they drastically go down. This is really purzzling, as I am watching GC Gen 0, GC Gen 1, and GC Gen 2 counters, and they all increment so I would think that Private Bytes would be managed better. So the infrequent drastic drop in Private Bytes is puzzling. Virtual Bytes, on the other hand, never go down.
I am trying memory comparisions between WindDbg breakpoints, but that isn't going all that quickly
|
|
|
|
|
Does your app do any kind of memory mapping? That would contribute to the Virtual bytes counter as well.
|
|
|
|
|
Senthil,
no, no memory mappings. Since I don't know how StreamWriter uses memory, one thing that I'd think can potentially cause problems is me writing large (GBs) log files.
It must be the unmanaged memory from the external unmanaged C++ library. I'm out of ideas as to what else can it be. The CLR profiler is showing no glaring problems with .Net-managed memory.
|
|
|
|
|
I did this!
private void lvFiles_SelectedIndexChanged(object sender, System.EventArgs e)
{
string filePath = lvFiles.SelectedItems.ToString();
ShellLib.ShellExecute shellExecute = new ShellLib.ShellExecute();
shellExecute.Verb = ShellLib.ShellExecute.OpenFile;
shellExecute.Path = @"F:\\Painel de Controle ETECH\\Projetos ETECH" + filePath;
shellExecute.Execute();
}
Am I close??
|
|
|
|
|
the event you're using will fire as you move down the list via keyboard or do single click selections. There should be a double click event. use that instead.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
|
Whenever I put a check mark on a ToolStripMenuItem it is misplaced (above the center), tried to google this bug but unsuccessful...does anyone else got this bug or is it just me? Is there any patch or will I have to custom draw the ToolStripMenuItem?
Thanx in advance
|
|
|
|
|
pacoxl wrote: does anyone else got this bug
Nope. Tried to replicate it and works fine here
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Forgot to mention: try making the ImageScalingSize of the Toolbar to 32x32
|
|
|
|
|
What did you eventually do to resolve the check mark issue? I've just encountered the same problem (VB 2008).
Thanks - AB
XAlan Burkhart
modified on Monday, September 5, 2011 2:45 PM
|
|
|
|
|
Hi All
What im trying to do is to connect three diffrent Treeview to the Sql Server in the same Database.
E.g.
Project-Database
ProjecTable1-Table inside Database
ProjectTable2
ProjectTable3
I have tried to connect but only one out of 3 tables will populate the treeview . So i am bit stuck.
If this does not make Sense please contact me craig.mutoko@iondale.com and i will explain.
I need Help Urgently.
Please Contact me
|
|
|
|
|
craigMUTOKOKAI wrote: Help Urgently
Umm no.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
craigMUTOKOKAI wrote: I need Help Urgently.
craigMUTOKOKAI wrote: contact me craig.mutoko@iondale.com
Hi Craig,
dont say that!!! you wont get post that way!!!
Good Luck
nelsonpaixao@yahoo.com.br
trying to help & get help
|
|
|
|
|
I have a very simple requirement.
1. The application takes a list of phrases (could be anything - topics, companies etc.) separated by comma or new line etc.
2. I click 'run', and the application does the following
a) picks each item from the list
b) queries google
c) picks the top 2 results from google
d) goes into the web site that is the result
e) downloads the page to some folder
Is there any utility like this I could get? help really appreciated.
-c
|
|
|
|
|
HTTrack[^] is a tool for creating off line copies of web pages.
If that doesn't do the job, the app you have described would be fairly simple to write.
You would load the file in, and build up a list of the queries.
Then loop though the list and build web requests to google for each one.
Parse the response and extract the urls for the first 2 results.
Send a request for the url and save the result to the folder.
If you get stuck on something specific, post a question here and I'll be happy to help.
Simon
|
|
|
|
|
Depending on how many companies you've got to list you may be banned from Google for a while because it's acting (well is) a bot. Actually one of the easier ways to do this many be on Linux.
|
|
|
|
|
Just a couple of hundred - not hundreds of thousands. Would that be a problem as well?
|
|
|
|
|
From what I remember the limit is 1,000 for the SOAP API but they're not creating new keys for it anymore (they were free). You can possibly create a local web-page and sign up for the AJAX query stuff to retrieve what you want, alternatively if you don't mind parsing HTML (just had a look at the format of the Google results page and it's pretty clean) you can just use a HttpWebRequest[^] object to form the request and retrieve stuff from that.
Have a search for Html Agility Kit which allows parsing of non-well formed html.
|
|
|
|
|
I have one form based program in VC#.
I found the following problem:
when I run it only one time, it takes only about 1 second.
but when I run it 20 times by using a loop, it takes far more than 1*20=20seconds, actually it takes even more than 100 seconds!
I think it may be because some memory or sources are not released during the loop. but I don't how to release the memory and sources for each loop.
I do hope some expert can give me some hints!
thank you very much!!
|
|
|
|
|
Post your loop code. I can't help you if I don't know what you are doing.
Simon
|
|
|
|
|
Hi,
the code is a little bit long, as follows:
simply speaking, I put several buttons in one panel, and each of them represents on function, then I just run the functions from the begining to the end.
private void toolStripButton_run_Click(object sender, EventArgs e)
{
Control[] control_panel = this.splitContainer1.Panel2.Controls.Find("panel_buffer", true);
DoubleBufferPanel double_panel = (DoubleBufferPanel)control_panel[0];
....
//////////////////////////////start normal simulaitons/////////////////////////////////////
this.toolStripStatusLabel_status.Text = "Overall simulation:";
this.toolStripStatusLabel_percent.Visible = true;
this.toolStripProgressBar1.Visible = true;
this.toolStripProgressBar1.Maximum = 10000;
textBox_simulation_output.Text += "Start the simulation ...";
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.Text += Environment.NewLine;
//Application.DoEvents();
//bool parameter indicate simulation is done normally
bool b_done = true;
//double parameter indicate the simulation time for one loop
double d_time_loop = 0;
if (b_stop == true)
{
b_done = false;
}
//start the simulation
if (b_stop == false)
{
// splitContainer1.Enabled = false;//disable the container1 during simulaiton
this.toolStripButton_stop.Enabled = true;//enable the stop button
this.stopSimulationToolStripMenuItem.Enabled = true;
if (b_user_loop == false)
{
loop1_max = 1;
loop2_max = 1;
loop3_max = 1;
}
int progress_n = 0;
int loop_count = 0;
for (int loop = 0; loop < loopmax; loop++)//for each loop
{
for (int loop1 = 0; loop1 < loop1_max; loop1++)
{
loop1_no = loop1;
for (int loop2 = 0; loop2 < loop2_max; loop2++)
{
loop2_no = loop2;
for (int loop3 = 0; loop3 < loop3_max; loop3++)
{
Stopwatch sw = new Stopwatch();//start to calculate
sw.Reset();
sw.Start();
loop3_no = loop3;
if (b_stop == true)
{
b_done = false;
break;
}
Application.DoEvents();
/////////////////////////////////////////status information set///////////////////////////////
double f_loop = Convert.ToDouble(loop);
double f_loopmax = Convert.ToDouble(loopmax);
string str_estimated_time = "";
if (b_time == true)
{
double d_time_left = d_time_loop / 1000 *
(loopmax * loop1_max * loop2_max * loop3_max - loop_count);
if (loop_count == 0)
{
str_estimated_time = "Time: " + "unknow, ";
}
else
{
str_estimated_time = "Time: " + Convert.ToInt32(d_time_left).ToString() + "s, ";
}
}
string str_iteration = "";
if (b_iteration == true)
{
str_iteration = "";
if (loopmax > 1)
{
str_iteration += "Loop:" + (loop + 1).ToString() + ", ";
}
if (loop1_max > 1)
{
str_iteration += "Loop1:" + (loop1_no + 1).ToString() + ", ";
}
if (loop2_max > 1)
{
str_iteration += "Loop2:" + (loop2_no + 1).ToString() + ", ";
}
if (loop3_max > 1)
{
str_iteration += "Loop3:" + (loop3_no + 1).ToString() + ", ";
}
}
if ((b_time == true) || (b_iteration == true))
{
this.toolStripStatusLabel_percent.Text = str_iteration + " " + str_estimated_time;
}
loop_no = loop;//for each module's static parameters, such as Data.reg
dic_moudle_out.Clear();
/////////////////////////////////////////////////call the module function by reflection///////////////////
for (int i = 0; i < module_list.Count; i++)
{
//change the current running module color
textBox_simulation_output.Text +="current running module: "+ module_list[i];
textBox_simulation_output.Text += Environment.NewLine;
progress_n ++;
this.toolStripProgressBar1.Value = Convert.ToInt32(progress_n / (module_list.Count*f_loopmax * loop1_max * loop2_max * loop3_max)
* this.toolStripProgressBar1.Maximum);
Application.DoEvents();
string str_percent = "";
if (b_ratio == true)
{
str_percent =Convert.ToInt32(100*progress_n / (module_list.Count*f_loopmax * loop1_max * loop2_max * loop3_max)).ToString() + "%";
this.toolStripStatusLabel_percent.Text = str_percent + " " +
str_iteration + " " + str_estimated_time;
}
if (b_module == true)
{
for (int j = 0; j < double_panel.Controls.Count; j++)
{
if ((((MyButton)double_panel.Controls[j]).level == 1)
&& (((MyButton)double_panel.Controls[j]).Name.ToString() == module_list[i]))
{
((MyButton)double_panel.Controls[j]).BackColor = Color.Red;
}
else
{
((MyButton)double_panel.Controls[j]).BackColor = Color.White;
}
}
}
//check the moudle is labeled pass or not
bool b_pass = false;
for (int j = 0; j < double_panel.Controls.Count; j++)
{
if ((((MyButton)double_panel.Controls[j]).level == 1)
&& (((MyButton)double_panel.Controls[j]).Name.ToString() == module_list[i])
&& (((MyButton)double_panel.Controls[j]).b_pass == true))
{
b_pass = true;
}
}
string str_module = "";
if (b_module == true)
{
str_module = "Moudle: " + module_list[i].ToString()+", ";
this.toolStripStatusLabel_percent.Text = str_percent + ", " +
str_iteration + " " + str_estimated_time + " " + str_module;
this.toolStripStatusLabel_percent.Invalidate();
}
if (b_stop == true)
{
b_done = false;
break;
}
Application.DoEvents();
// for input parameter of module i
Dictionary<string,>> dic_in_temp = new Dictionary<string,>>();
//for those modules with input, i.e. in_no!=0
if (list_in[i] != 0)
{
List<string> path_in = new List<string>();//save all the in path string for module i
//for each module, check the input path
foreach (KeyValuePair<string,> kvp in path)
{
if (kvp.Key.Contains(module_list[i].ToString() + "*in*no*"))
{
path_in.Add(kvp.Key.ToString());
}
}
//list the path_in in the right order according to the input no 0,1,2...
for (int m = 0; m < path_in.Count; m++)//loop in order to list all the path_in in the right order
{
for (int j = 0; j < path_in.Count - 1; j++)
{
string str_in_no_1 = path_in[j].Substring(path_in[j].IndexOf("*in*no*") + 7, 1);//the no of input and output is assumed to be less than 10
string str_in_no_2 = path_in[j + 1].Substring(path_in[j + 1].IndexOf("*in*no*") + 7, 1);//the no of input and output is assumed to be less than 10
if (Convert.ToInt16(str_in_no_1) > Convert.ToInt16(str_in_no_2))//exchange
{
string str_temp = path_in[j];
path_in[j] = path_in[j + 1];
path_in[j + 1] = str_temp;
}
}
}
//obtain the module out and the out no for each path_in,
//save the input parameters for module i
for (int m = 0; m < path_in.Count; m++)
{
string str_module_out = path_in[m].Substring(0, path_in[m].IndexOf("*out*no*"));
string str_out_no = path_in[m].Substring(path_in[m].IndexOf("*out*no*") + 8, 1);
Dictionary<string,>> dic_out_temp = new Dictionary<string,>>();
dic_moudle_out.TryGetValue(str_module_out, out dic_out_temp);
List<para_in_out> list_out_temp = new List<para_in_out>();
dic_out_temp.TryGetValue(str_out_no, out list_out_temp);
dic_in_temp.Add(m.ToString(), list_out_temp);
}
}
//get the module name without the no "_0"
string str = module_list[i].ToString();
string str_function = str.Substring(0, str.IndexOf("*"));
#region reflection functions
//for the modules without input
object out_temp = new object();
if (list_in[i] == 0)
{
try
{
bool b_module_non_dll = false;
for (int k = 0; k < str_module_list.Count; k++)
{
if (str_function == str_module_list[k])
{
b_module_non_dll = true;
}
}
if (b_module_non_dll == true)
{
//directly call the functions:olkd
out_temp = this.GetType().InvokeMember(str_function, BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance, null, this, new object[] { module_list[i] });
}
else
{
string str_dll = str_module_dll_path;
str_dll = str_dll + "\\" + str_function + ".dll";
AssemblyName name = new AssemblyName();
name.CodeBase = "file://" + str_dll;
Assembly asm = AppDomain.CurrentDomain.Load(name);
// Instantiate the class
string str_namespace_class = "NS_" + str_function + "." + "Class_" + str_function;
object remoteObject =
asm.CreateInstance(str_namespace_class);
Type remoteType =
asm.GetType(str_namespace_class);
// Call the method
MethodInfo method = remoteType.GetMethod(str_function + "_fun");
out_temp = method.Invoke(remoteObject, new object[] { module_list[i], module_value, loop_no, b_stop });
}
}
catch (TargetInvocationException ex)
{
MessageBox.Show(ex.InnerException.ToString());
splitContainer1.Enabled = true;//enable the container1 during simulaiton
return;
}
}
else
{
try
{
bool b_module_non_dll = false;
for (int k = 0; k < str_module_list.Count; k++)
{
if (str_function == str_module_list[k])
{
b_module_non_dll = true;
}
}
if (b_module_non_dll == true)
{
if (b_pass == true)
out_temp = this.GetType().InvokeMember(str_function + "_pass",
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, this, new object[] { module_list[i], dic_in_temp });
else
out_temp = this.GetType().InvokeMember(str_function,
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, this, new object[] { module_list[i], dic_in_temp });
}
else
{
string str_dll = str_module_dll_path;
str_dll = str_dll + "\\" + str_function + ".dll";
AssemblyName name = new AssemblyName();
name.CodeBase = "file://" + "\\" + str_dll;
Assembly asm = AppDomain.CurrentDomain.Load(name);
// Instantiate the class
string str_namespace_class = "NS_" + str_function + "." + "Class_" + str_function;
object remoteObject =
asm.CreateInstance(str_namespace_class);
Type remoteType =
asm.GetType(str_namespace_class);
// Call the method
MethodInfo method = remoteType.GetMethod(str_function + "_fun");
out_temp = method.Invoke(remoteObject, new object[] { module_list[i], module_value, dic_in_temp, loop_no, b_stop });
}
}
catch (TargetInvocationException ex)
{
MessageBox.Show(ex.InnerException.ToString());
splitContainer1.Enabled = true;//enable the container1 during simulaiton
return;
}
}
#endregion reflection functions
//save output for each module with output
Dictionary<string,>>> dic_moudle_out_temp = new Dictionary<string,>>>();
dic_moudle_out_temp = (Dictionary<string,>>>)out_temp;
if (out_temp != null) //avoid for the modules without output
{
foreach (KeyValuePair<string,>>> kvp in dic_moudle_out_temp)
{
dic_moudle_out.Add(kvp.Key, kvp.Value);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////// modules loop: start ////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
#region modules loop
//check whether current module belongs to the end module of some module loops:
List<mybutton> list_loop_modules = new List<mybutton>();
int loop_modules_no = 0;
string str_current_loop_name = "";
foreach (KeyValuePair<string,>> kvp in dic_module_loop)
{
if (module_list[i] == kvp.Value[kvp.Value.Count - 1].Name)
{
dic_module_loop.TryGetValue(kvp.Key, out list_loop_modules);
dic_module_loop_no.TryGetValue(kvp.Key, out loop_modules_no);
str_current_loop_name = kvp.Key;
}
}
//if so, then loop these modules
if (list_loop_modules.Count != 0)
{
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.Text += "current running loop: " + str_current_loop_name;
textBox_simulation_output.Text += Environment.NewLine;
for (int ii = 1; ii < loop_modules_no; ii++) //start from 1 not 0 because one loop has calculated
{
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.Text += "current running loop no: " + ii.ToString();
textBox_simulation_output.Text += Environment.NewLine;
for (int i_loop = 0; i_loop < list_loop_modules.Count; i_loop++)
{
textBox_simulation_output.Text += "current running module : " + list_loop_modules[i_loop].Name;
textBox_simulation_output.Text += Environment.NewLine;
//change the current running module color
for (int j = 0; j < double_panel.Controls.Count; j++)
{
if ((((MyButton)double_panel.Controls[j]).level == 1)
&& (((MyButton)double_panel.Controls[j]).Name.ToString() == list_loop_modules[i_loop].Name))
{
((MyButton)double_panel.Controls[j]).BackColor = Color.Red;
}
else
{
((MyButton)double_panel.Controls[j]).BackColor = Color.White;
}
}
//check the moudle is labeled pass or not
bool b_pass_loop = false;
for (int j = 0; j < double_panel.Controls.Count; j++)
{
if ((((MyButton)double_panel.Controls[j]).level == 1)
&& (((MyButton)double_panel.Controls[j]).Name.ToString() == list_loop_modules[i_loop].Name)
&& (((MyButton)double_panel.Controls[j]).b_pass == true))
{
b_pass_loop = true;
}
}
string str_module_loop_modules = "";
if (b_module == true)
{
str_module_loop_modules = "Moudle: " + list_loop_modules[i_loop].Name.ToString();
string str_modules_loop_current = "loop:" + str_current_loop_name + " #" + (ii + 1).ToString();
this.toolStripStatusLabel_percent.Text = str_percent + " "
+ str_iteration + " " + str_estimated_time + " "
+ str_modules_loop_current + " " + str_module_loop_modules;
}
if (b_stop == true)
{
b_done = false;
break;
}
Application.DoEvents();
//for the first module in the loop, the input is assigned by the output,i.e., the last module
// for input parameter of module i
Dictionary<string,>> dic_in_temp_loop = new Dictionary<string,>>();
//for those modules with input, i.e. in_no!=0
if (list_loop_modules.Count != 0)
{
List<string> path_in = new List<string>();//save all the in path string for module i
//for each module, check the input path
foreach (KeyValuePair<string,> kvp in path)
{
if (kvp.Key.Contains(list_loop_modules[i_loop].Name.ToString() + "*in*no*"))
{
path_in.Add(kvp.Key.ToString());
}
}
//list the path_in in the right order according to the input no 0,1,2...
for (int m = 0; m < path_in.Count; m++)//loop in order to list all the path_in in the right order
{
for (int j = 0; j < path_in.Count - 1; j++)
{
string str_in_no_1 = path_in[j].Substring(path_in[j].IndexOf("*in*no*") + 7, 1);//the no of input and output is assumed to be less than 10
string str_in_no_2 = path_in[j + 1].Substring(path_in[j + 1].IndexOf("*in*no*") + 7, 1);//the no of input and output is assumed to be less than 10
if (Convert.ToInt16(str_in_no_1) > Convert.ToInt16(str_in_no_2))//exchange
{
string str_temp = path_in[j];
path_in[j] = path_in[j + 1];
path_in[j + 1] = str_temp;
}
}
}
//obtain the module out and the out no for each path_in,
//save the input parameters for module i
if (i_loop == 0) //the input into the first module: the output of the last module
{
string str_module_out = list_loop_modules[list_loop_modules.Count - 1].Name;
string str_out_no = "0";
Dictionary<string,>> dic_out_temp_loop = new Dictionary<string,>>();
dic_moudle_out.TryGetValue(str_module_out, out dic_out_temp_loop);
List<para_in_out> list_out_temp_loop = new List<para_in_out>();
dic_out_temp_loop.TryGetValue(str_out_no, out list_out_temp_loop);
dic_in_temp_loop.Add(str_out_no, list_out_temp_loop);
}
else //the input into the other modules: the output from the previous ones
{
for (int m = 0; m < path_in.Count; m++)
{
string str_module_out = path_in[m].Substring(0, path_in[m].IndexOf("*out*no*"));
string str_out_no = path_in[m].Substring(path_in[m].IndexOf("*out*no*") + 8, 1);
Dictionary<string,>> dic_out_temp_loop = new Dictionary<string,>>();
dic_moudle_out.TryGetValue(str_module_out, out dic_out_temp_loop);
List<para_in_out> list_out_temp_loop = new List<para_in_out>();
dic_out_temp_loop.TryGetValue(str_out_no, out list_out_temp_loop);
dic_in_temp_loop.Add(m.ToString(), list_out_temp_loop);
}
}
}
//get the module name without the no "_0"
string str_loop = list_loop_modules[i_loop].Name.ToString();
string str_function_loop = str_loop.Substring(0, str_loop.IndexOf("*"));
//for the modules without input
object out_temp_loop = new object();
//call reflection functions
try
{
bool b_module_non_dll = false;
for (int k = 0; k < str_module_list.Count; k++)
{
if (str_function == str_module_list[k])
{
b_module_non_dll = true;
}
}
if (b_module_non_dll == true)
{
if (b_pass_loop == true)
out_temp_loop = this.GetType().InvokeMember(str_function_loop + "_pass",
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, this, new object[] { list_loop_modules[i_loop].Name, dic_in_temp_loop });
else
out_temp_loop = this.GetType().InvokeMember(str_function_loop,
BindingFlags.InvokeMethod | BindingFlags.NonPublic | BindingFlags.Instance,
null, this, new object[] { list_loop_modules[i_loop].Name, dic_in_temp_loop });
}
else
{
string str_dll = str_module_dll_path;
str_dll = str_dll + "\\" + str_function + ".dll";
AssemblyName name = new AssemblyName();
name.CodeBase = "file://" + "\\" + str_dll;
Assembly asm = AppDomain.CurrentDomain.Load(name);
// Instantiate the class
string str_namespace_class = "NS_" + str_function_loop + "." + "Class_" + str_function_loop;
object remoteObject =
asm.CreateInstance(str_namespace_class);
Type remoteType =
asm.GetType(str_namespace_class);
// Call the method
MethodInfo method = remoteType.GetMethod(str_function_loop + "_fun");
out_temp = method.Invoke(remoteObject, new object[] { list_loop_modules[i_loop].Name,
module_value, dic_in_temp_loop, loop_no, b_stop });
}
}
catch (TargetInvocationException ex)
{
MessageBox.Show(ex.InnerException.ToString());
splitContainer1.Enabled = true;//enable the container1 during simulaiton
return;
}
//update the output for each module in the loop
Dictionary<string,>>> dic_moudle_out_temp_loop = new Dictionary<string,>>>();
dic_moudle_out_temp_loop = (Dictionary<string,>>>)out_temp_loop;
if (out_temp_loop != null) //avoid for the modules without output
{
foreach (KeyValuePair<string,>>> kvp in dic_moudle_out_temp_loop)
{
dic_moudle_out.Remove(kvp.Key);
dic_moudle_out.Add(kvp.Key, kvp.Value);
}
}
}
}
}
#endregion modules loop
}//end: for each module
if (loop_count == 0) //only calculate one time for time estimation
{
sw.Stop();
d_time_loop = sw.ElapsedMilliseconds;
}
loop_count++;
}//end: loop 3
}//end: loop 2
}//end: loop 1
}//end: loop
}//end: for b_stop==false
if (b_done == true)
{
sw_total.Stop();
double d_time_total = sw_total.ElapsedMilliseconds / 1000;
this.toolStripStatusLabel_status.Text = "Simulation is done, total time is:"
+ (Convert.ToInt32(d_time_total)).ToString() + "s";
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.Text += this.toolStripStatusLabel_status.Text;
textBox_simulation_output.Text += Environment.NewLine;
this.toolStripButton_output_observer.Enabled = true;
this.outputWindowToolStripMenuItem.Enabled = true;
b_simulation_complete = true;
}
else
{
this.toolStripStatusLabel_status.Text = "Simulation is stopped";
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.Text += "Simulation is stopped";
textBox_simulation_output.Text += Environment.NewLine;
textBox_simulation_output.ScrollToCaret();
}
//splitContainer1.Enabled = true;//enable the container1 during simulaiton
this.toolStripProgressBar1.Visible = false;
this.toolStripStatusLabel_percent.Visible = false;
this.toolStripButton_stop.Enabled = false;//disable the stop button
this.stopSimulationToolStripMenuItem.Enabled = false;
//close all figures button
if ((dic_form.Count > 0) || (dic_form_single.Count > 0))
{
toolbutton_close_all_figure.Enabled = true;
Menu_Close_all_Figure.Enabled = true;
}
}
|
|
|
|
|
I meant post just the bit of code that does the looping.
1) What on earth is this meant to mean?
Dictionary<string,>>>
You need to escape any < or > signs in your code with < or > before you can post them.
2) Code should be posted within <pre> </pre> tags to make it more readable.
if(testValue)
{
Console.WriteLine("test");
}
Simon
|
|
|
|
|
Hi, Simon,
by the way, I saw one simulaiton tool, they provide one button to "clear the simulation", then it gives the message "Clearing memory of the simulation". that means the memory used by the simulation has been cleared. I don't know how to clear the memory used by the simulaiton? If I know how to do it, it may help me to improve my own simulation tool, especially when we have many loops.
Do you have the experiences on it?
thank you for your kind help!!
|
|
|
|
|
In .net you don't need to clear memory. Most .net objects are "managed" which means their memory is automatically reclaimed by the garbage collector, provided you don't hold references too them after they should have gone out of scope, so you don't need to worry about it.
When a class uses unmanaged memory, it will implement the IDisposable interface. In this case, you just call the Dispose() method when you are finished with it to release the objects unmanaged memory.
I've only briefly looked over your code, but I can't see any types in there that need disposing of.
Simon
|
|
|
|
|