|
:bashhead:
-_-
Ok, now it works (Once...)
Benchmark code modified to:
private void button2_Click(object sender, EventArgs e)<br />
{<br />
StreamReader sr = new StreamReader(@"C:\benchMe.txt");<br />
string bob = sr.ReadToEnd();<br />
sr.Close();<br />
timer1.Start();<br />
Console.WriteLine(bob);<br />
timer1.Stop();<br />
MessageBox.Show("Marks on Test: " + marks);<br />
marks = 0;<br />
}
First click displays marks, second click -> x click displays 0.
So close....
|
|
|
|
|
|
You have mentioned the timer interval as 1ms. If the interval is less than 15ms (sometimes this will be more according to the processor/hardware.) it is not going to perform correctly.
This article will explain it clearly.
Timer surprises, and how to avoid them[^]
*jaans
|
|
|
|
|
D:
Never knew that!
Thanks alot!!!
- Reelix
|
|
|
|
|
I read this a couple of times, and I'm not 100% sure what all of it is doing, so forgive me if Im a little off the mark with this...
Have you looked at System.Diagnostics.Stopwatch at all?
If what you are going for is performance testing you could have something like:
const int NumberOfTests = 1000000;
System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch();
s.Start();
for (int i = 0; i < NumberOfTests; i++)
{
//Code to test goes here!
}
s.Stop();
MessageBox.Show(s.ElapsedMilliseconds.ToString());
(Rinse and repeat for multiple benchmarks)
Hope that helps,
Chris
|
|
|
|
|
Thanks alot!
It perfected everything
YAY!
IsHappy("Reelix") == true;
|
|
|
|
|
Glad to have helped!
Chris
|
|
|
|
|
Hi
I have to display more than one button control Within a Single column of Grid control.
How can i Achieve this? can anyone help me?
thanks in advance
bye
sri
|
|
|
|
|
Hi
You can use TemplateColumn and add as many as button within the template column.
Harini
|
|
|
|
|
Hi Sri,
I have another way to do this, we can take the following steps:
1). Make a usercontrol to host buttons, the CustomButtonControl class which inherited from usercontrol.
2). Create a CustomButtonControl instance(NOTICE: we just need one), add it into the control collection of the DataGridView, initially make it invisible.
3). Handle the DataGridView.CellPainting event to draw a textbox and button style on the cell, which make the cell looked like some kind hosting a usercontrol in it.
4). Handle the DataGridView.CellBeginEdit event to show the usercontrol right in the cell while editing, you can edit in the textbox in the usercontrol and click the button, write your logic in the Click event of the button, I just show a message box for example in this sample.
5). Handle the DataGridView.CellEndEdit event to update the cell value.
6). Handle the DataGridView.Scroll event to reset the location and size of the usercontrol while scrolling. Without handling this, the usercontrol would stay still while scrolling.
Hope this will help you in moving forward in your task .
Regards,
John Adams
ComponentOne LLC
|
|
|
|
|
Hi,
I have an struct of BookMarkInfo ,
struct BkMarkInfo
{
public String bkMarkName;
public double X, Y, Z;
}
// Statically allocating memory for 10 objects initially
BkMarkInfo[] BkMark = new BkMarkInfo[10];
Later i need another 5 objects of same struct BkMarkInfo. How can i dynamically allocate memory for struct object?
Thanks
~Devil
|
|
|
|
|
Use List<t> instead if array
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
As Giorgi already said, use a list:
List<BkMarkInfo> BkMark = new List<BkMarkInfo>();
Use a class instead of a struct. You have made a mutable struct, which is not very practical. This, for example, doesn't work as expected:
BkMark[4].bkMarkName = "document";
When you access the struct, it will be copied into a temporary variable. The bkMarkName in the temporary variable is changed, but that won't affect the bkMarkName of the struct in the list.
Also, a struct should not be larger than 16 bytes. Yours is about twice that size.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi all,
I am using the software upgrade process within Visual Studio to perform the software upgrade. The problem is that everytime I perform an upgrade, the existing configuration file gets wiped. What must I do to prevent this?
Many thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi My Friends,
I write a program with C#, that after clicking button OpenFileDialog appear and you can select a text file and then my program read the text file and insert into Database.
This program work good and no problem but after click select and open text file in the OpenFileDialog about 2 or 3 second (depend to the size of file)
below picture appear :
http://www.freewebs.com/autoclinic/images/untitled.gif[^]
I want to know how can prevent this action ?
Best Regards,
Reza Shojaee
|
|
|
|
|
Your program's UI freezes because it is busy reading txt file and inserting it into database so it has no time to repaint itself. Try moving the file processing code into a new thread.
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Thanks for your guidance,
If I don't want use multithread programming.Can repaint form manually before insert data into database?
Best Regards,
Reza Shojaee
|
|
|
|
|
Try Application.DoEvents() method
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Special thanks for you.
my problem solved.
Best Regards,
Reza Shojaee
|
|
|
|
|
Hello everyone,
1.
I have checked MSDN document,
http://msdn2.microsoft.com/en-us/library/kzy257t0(VS.80).aspx
it does not cover what is the function of WaitOne if we assign 0 as the timeout parameter.
I think the function of assigning 0 is to check whether the signal is set or not, and it will be returned immediately, right?
2.
If WaitOne (0, true) returns true, it means the signal is set or not set?
thanks in advance,
George
|
|
|
|
|
Hi
iam in windows application using c#.
my database is "FireBird Database".
Database path is :
string dsRelativePath = "database\\absolutemedia.fdb";
string dsAbsolutePath = Path.GetFullPath(dsRelativePath);
string ConnectionString = "ServerType=1;User=SYSDBA;Password=masterkey;Database=" +dsAbsolutePath;
This path is working fine upto now..
but in my application, i have an option to upload images from local drives..iam browisng an image thru "OpenFileDialog".. after selecting an image .when iam going to save ,
database path i,e dsAbsolutePath is changed to image path.it's giving error in database connection...
please reply where the problem is ?
how can i rectify this .
murali krishna
|
|
|
|
|
I think u are setting the image path in dsRelativePath after the image is selected...check that ...if so store the path in different variable
.....
|
|
|
|
|
Hi,
Thanks for Reply..
Here iam not setting ImagePath to "dsAbsolutePath";
iam taking Imagepath to another string.
murali krishna
|
|
|
|
|
i don't understand how come image path value is taken in dsAbsolutePath without setting it ...declare the dsAbsolutePath and dsRelativePath variables as constants and see if the error still occurs..can u post your code ?
.....
|
|
|
|
|
Dear all,
Can anyone help me to do bandwidth programming in C# 2003? If anyone aware of this kindly, forward me source code of sample project and also your mail id. So, I could contact you later as if I've doubt on that
|
|
|
|