|
Awwww. That's not fair. I want my code to leak memory like a sieve just because I might want to use a variable again at some point in the future. I know - I'll make everything global static, then that will solve everything; oh wait my program's taken up all of the stack space.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Any reason you want a member variable, and NOT define it as such ?
One thing you can do is define an anonymous method for an event, inside this method. The variables inside the method are then scoped to that code. So, if you do this:
StreamReader SR = new StreamReader(@"C:\test.txt");
myTimer.Tick += new delegate()
{
SR.Read();
}
Assuming that Read is a parameterless method on the streamreader, this would work.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
how to calculate the code execution time in nanoseconds
|
|
|
|
|
You can use the System.Diagnosics.Stopwatch class.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: use the System.Diagnosics.Stopwatch class
But the OP wanted in nanoseconds. Only way I think that can be achieved is through an unmanaged .dll using the rdtsc instruction...I've got one around here, maybe I should write out a quick article on it
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Right, the StopWatch class only gives microsecond resolution.
I wonder if the OP really needs nanosecond resolution, or if he meant microseconds...
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: I wonder if the OP really needs nanosecond resolution
I wondered the same thing. I find the .dll utility class that I created that works with rdtsc as being a bit too granular, but it's there if I need to get that fine of a resolution.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
I have a problem:
I have a class that contains some classes that have some basic types in it, something like this:
class mainClass
{
class oneType
{
public string name = "The One Name";
public string adress = "The One Adress";
public bool isMoving = true;
}
class twoType
{
public string name = "The Two Name";
public string adress = "The Two Adress";
public bool isMoving = false;
}
}
Can someone tell me how can I iterate through the mainClass and take out values for each class in it (class oneType and twoType). I wont to use foreach loop to do some operation on the values in each class. It's maybe smarter to use some other type to describe oneType and twoType.
Please answer, it's urgent. Thanks!
d97kti
|
|
|
|
|
I'd create a base class for all these classes, then create a list of classes. Of course, you need a list of class *instances*, you can't iterate over the classes themselves, they don't actually exist anywhere ( you have a prototype, but no instance of any class to contain any values )
d97kti wrote: Please answer, it's urgent.
Of course it is....
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks, i 'll try something out. I can't get it to work just fine. I will probably use arrays instead. But thanks any way.
Chears
|
|
|
|
|
I am writing an app where I want to use a round rectangle window with no caption, but still able to size it. I tried to send message WM_SIZE, but no success. Any Idea?
We can set the region to set the shape of the window, but after changing to new size I think we have to call set region again. Any feedback will be very much appreciated.
agha.khan@hotmail.com
best regards
:->
Agha Khan
|
|
|
|
|
I am writing an app where I want to use a round rectangle window with no caption, but still able to size it. I tried to send message WM_SIZE, but no success. Any Idea?
We can set the region to set the shape of the window, but after changing to new size I think we have to call set region again. Any feedback will be very much appreciated.
agha.khan@hotmail.com
Agha Khan
|
|
|
|
|
Don't ask twice.
You'd do it yourself, just capture the mouse when it's clicked on the edge, and resize in your code as your mouse moves.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Dear Christian Graus:
I am not sure how I asked twice? It was not my attention.
When we want to remove the caption we need to remove sizeable attribute. After that we will never receive any message or event that tells us that mouse is on edge. Perhaps you have something else in your mind.
Do you any other way to remove caption?
I worked on Fortran while back. I am not sure but you may still ask me any question on FORTRAN. I uesed to be good, but I do not know yet.
Best regards
Agha Khan
agha.khan@hotmail.com
Agha Khan
|
|
|
|
|
AghaKhan wrote: I am not sure how I asked twice? It was not my attention.
Your question was posted twice.
AghaKhan wrote: . After that we will never receive any message or event that tells us that mouse is on edge.
That's right, you need to track this yourself, from the mouse position.
AghaKhan wrote: I worked on Fortran while back.
I never have, you're responding to my sig block, it's not a comment from me to you.
Are you using C# ? I suddenly wonder if you're in the wrong forum, and using C++
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello
i don't know why i can't save this record in the database
there is no error and every thing is fine but i can't see the new data in the database
this is the code:
"con.Open();
str3 = "INSERT INTO [CreditCard].[dbo].[CreditCardInfo] ([CreditTypeID],[CreditcardNumber],[CustomerName],[BankID],[ExpiryDate],[EntryDate],[MachineTypeID]) VALUES((" + crId + "),(" + crNum + "),('" + Name + "'),(" + bnkId + "),('" + dtm + "'),('" + now + "'),(" + mId + "))";
cmd = new SqlCommand(str3, con);
adap.InsertCommand = cmd;"
i verify the insert statment in the SQL and it save the data
any help ???
Thanks in advance
Assaf
|
|
|
|
|
If you grab the SQL from the debugger and paste it into your database, what happens ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
the data is inserted in the table
Assaf
|
|
|
|
|
What if you check the DB after running the code, might the issue be that the data has changed and your app is not refreshing it's data source ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I checked but there is no change
Assaf
|
|
|
|
|
Then your code that passes the SQL to the data base is plainly where the problem is. You can check when you call the data layer as to how many rows were affected, that's a good place to start.
Using stored procs is another option worth exploring. Depending on where your data comes from, your current code could have you wide open for injection attacks.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
The problem is when i execute the code no row is affected un the database
but when i take the insert statment from the watch and execute it in the SQL i can saw that one row is affected
so i wonder do from the code.
Assaf
|
|
|
|
|
Then your SQL is fine, and your code to call the database is broken. As I said.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
you mean the connection string but i use it before to retreive data from the same database and it succeed
Assaf
|
|
|
|
|
Not necessarily, I mean that somewhere you're supposed to call some code and you're not. I don't use the nasty built in SQL insert/update/delete stuff, so I can't help much more, but that's plainly where the issue is. That's just common sense.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|