|
Yeah, that's not a good idea since a crashed application can invalidate the count.
|
|
|
|
|
heum true
didn't think that far ahead
been a very long day but hey only half an hour to go ;P
PS: the first option would work even with crashed application (but might be a bit of a work around)
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
How would that code look like?
|
|
|
|
|
TDDragon wrote: PS: the first option would work even with crashed application (but might be a bit of a work around)
It is. Most people who use this technique will hard code the name of the .EXE in their code. What if the .EXE get's renamed by either the end-user or the guy writing the code??
|
|
|
|
|
Normal practice is to use a Mutex. Search the articles for "single instance[^]" for examples.
You application starts by checking for the existance of a known Mutex. If it doesn't exist, your code then creates the Mutex. At the termination of your app, you have to destroy the Mutex.
Now, when your second instance starts, the very same code checks for the existance of the Mutex. If it's there, your code could quit, or do whatever else you want.
|
|
|
|
|
If you are using VS2005, right click the project and click properties. On the application tab there is a checkbox that says 'Make single instance application'. If you check that then compile, it should solve your problems. If you are using VS2003 you will need to do what Dave said.
Mike Lasseter
|
|
|
|
|
Dear All,
When i executing my VB.NET project, an error message displays time to time as follows,
An unhandled exception of type 'System.NullReferenceException' occurred in system.windows.forms.dll
Additional information: Object reference not set to an instance of an object.
Always this is displaying at Public Class Form1
anybody can help me
Dimuthu
|
|
|
|
|
this means that you are using a variable before it has been initialized
for example
private sub blabla()
dim l as list(of string)
l.add("this is going to give a object referance not set to an instance of an object error")
end sub
solution:
private sub blabla()
dim l as NEW list(of string)
l.add("this is going to give a object referance not set to an instance of an object error")
end sub
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
Dear TDDragon,
Thanks, I checked all the variables, but they have all initialyzed. Stll the problem remaining.
Dimuthu
|
|
|
|
|
declare the form as NEW instance of the form class
then show it
as:
dim f as new (Form class)
f.Show
Try
Dim SH*T as Mylife
Catch ex As Exception
msgbox("Im Happey Today")
End Try
|
|
|
|
|
Dear all,
I know that this is not a new query. On the other hand I didn't manage to find a satisfactory answer.
So here I am.
I have a VB .NET application, which employs various CPU consuming algorithms.
I want to measure the execution time of a code snippet. Not the real time, but
the actual time that my code uses the CPU. Do be more accurate, I want to
have a CPU independent unit for comparison.
Apart the above question, is there any general platform independent method or unit to
characterize the execution speed of an application.
Than you all.
Konstantinos
|
|
|
|
|
Usually, CPU intensive tasks use almost 100% of the CPU time, so the common way of measuring execution time is to make sure that the computer isn't doing anything else that is CPU intensive, and just measure the time spent.
The System.Diagnostics.StopWatch class is suitable for this.
There is no CPU independent or platform independent way to characterise execution speed. The speed is very much dependent on the CPU architecture, like cache sizes, memory speed, pipeline stall penalties, branch prediction, et.c. The efficiency of a specific combination of instructions can vary considerably from one computer to another.
---
single minded; short sighted; long gone;
|
|
|
|
|
Thank you Guffa.
I already use stopwatch, but do you know if it counts the Real time passed or the allocated CPU time to the process, like the clock() function from C++?
If stopwatch measures real time, do you believe that it would be possible to be corrected in
some way by the allocated "% user time" (performance counter) of the process. As an example
lets say that a process runs from 2500 ms and the average process [% user time] is 80%. Is
it applicable to say [virtual time]=2500 ms x 80%= 2000 ms....
Konstantinos
|
|
|
|
|
hi,
i have a question: What event is used to resize the column of a datagridview?
thanks.
|
|
|
|
|
None. Events don't cause the resize to happen.
|
|
|
|
|
Hi,
I have an array of couple of millions of fields as byte.
The problem is In my function i need to resize the array everytime I pass through the function.
Using redim preserve array(i + someBigNumber)
And it is to slow... But speed in my app is a crucial argument.
Is there any faster way to resize the array and keep it's contents?
|
|
|
|
|
USe a list instead, it's a dynamic array. Which means the name 'list' sucks, but that's .NET for you.
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 )
|
|
|
|
|
no...
but try to make a copy of this array by array. lib functions
Try
Dim SH*T as Mylife
Catch ex As Exception
msgbox("Im Happey Today")
End Try
|
|
|
|
|
|
1. Post a question normally, give a title and ask a question don't ask your question in your title and just say pls help.
2. You want findstring and you want to on textbox text changed, call this with the listbox and use the text as the string to check against. Check this out
|
|
|
|
|
good day again friends,
i again need your help on this one about datagridview in vb.net2005:
- i created a runtime columns which contains combobox control/ datagridviewcomboboxcolumn
- i set its datasource, and it runs smoothly
- my problem was, i dont know how to add another value which at the runtime of the application created, and display on the grid on the location where the combobox column located.
can someone help me on this... thank you...
your help; ideas, link, codes... are highly appreciated..
thank you
start a new beginning in every ending; thats what life for......
|
|
|
|
|
When i first started VB6 i used to hard code constants into a separate Module.
Then i moved on to using an ini file instead as this allowed me to change server paths and server names
plus other info without the need for recompiling code.
Now i'm onto and new to VB.NET i want to adopt a good practise and have started using an xml file instead which i then read into the application to initialise certain system properties.
What i want to know is what other people are doing or is there a better standard that
folks are using?
Many Thanks
|
|
|
|
|
don't know if this exist in 2003 but in 2005 there is a tab 'settings' on the properties of you'r project
here you can give a settingname, type, scope and value
this does exactly the same as what you do with the plus side that you can access these 'settings' in code like this:
my.Settings.nameofsetting
it basacly creates a xml file wich can be opened in notepad to alter it
I always use this
If my help was helpfull let me know, if not let me know why.
The only way we learn is by making mistaks.
|
|
|
|
|
:-DExcellent, thanks.
Just the thing i was looking for.
|
|
|
|
|
Hola,
I use a package called AutoMod to make simulation models and to send messages from VB to this package teh AutoMod help says to use the next code
Call amxEvents.CallFunction("FsetMotorState", Array(1, Range("B10").Value))
However when I use this code in VB 2005 I get an error message that Array is a type and cannot be used like this.
What do I have to do in VB to get an array as the second argument?
Thanks in advance,
Nasko
See below for the syntax of the CallFunction method.
amx.CallFunction(funcName, params)
The syntax elements are defined as follows:
Syntax Element
Description
amx
An object variable that refers to the AutoMod runtime object.
CallFunction
The name of the method.
funcName
A string that indicates the name of the function in the AutoMod model that you want to call.
params
An array of variants that define the arguments required by the user-defined AutoMod function. The array must have as many values as the AutoMod function has arguments (any extra values are ignored). The variant values are automatically converted to the type of the associated argument in the AutoMod function in the model.
Note: The params syntax element is required. If the AutoMod function you are calling has no arguments, you must still define an empty array. For example:
Call amx.CallFunction("FAmodFunction", Array())
'An empty array is passed to the AutoMod function FAmodFunction
|
|
|
|