|
hi.. regarding to this link in your website.. http://www.codeproject.com/csharp/charting.asp
i downloaded the source file.. and when i do it in my laptop.. the textbox with value come out... but when i click on the graph button... the page just disappear.. waht is wrong here?
|
|
|
|
|
I think it would be a better idea to ask the author of the article, don't you think?
I will use Google before asking dumb questions
|
|
|
|
|
Did you remember to fill your laptop screen with enough ink?
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
hi.. the author is Dave Brighton... but i cannot find his related email in his profile.. how do i connect to him?
what is the "ink" mean?thanks
|
|
|
|
|
I want to design a dll, which could be used by few applications, but this dll may not be run (or not be fully functioned) at same time. the requirement is:
1. the first application can create an instance of the dll with fully function.
2. while first application is runing, start second application, it may create an instance, but some of the function is disabled, or it may not create an instance of the dll. until the application 1 closed (or release the control), then the second application can use the fully function of the dll.
Can anybody tell me how I can design this kind of the dll project?
It seems that static variable in the class could not be used for this purpose. static variable is only valid with in an application, but could not be share within few applications. Is it true?
Thank you in advance.
lk
|
|
|
|
|
Sounds suspiciously like you need a singleton, but then again its not. Why on earth would you want something like this?
you can have something similar to the following:
<br />
private static int _NumberOfInstances = 0;<br />
<br />
Private static void InstanceCheck()<br />
{<br />
if(_NumberOfInstances > 1)<br />
throw new TooManyInstancesException();<br />
else<br />
_NumberOfInstances++;<br />
<br />
}<br />
<br />
public void Function1()<br />
{<br />
try<br />
{<br />
InstanceCheck()<br />
...<br />
...<br />
} <br />
catch (TooManyInstancesException tmiex)<br />
{<br />
throw tmiex;<br />
}<br />
}<br />
Each of your methods would be checking the number of instances that are already available. You can then limit the activities based on that.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
"Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"
|
|
|
|
|
hi
you could use a mutex[^] to check if the library is already in use or not.
greets
m@u
|
|
|
|
|
How can he use a mutex if static variables are not being persisted into different instances of the DLL?
Jeff
|
|
|
|
|
they don't have to.
if you start an application that creates a mutext with a specific name, and then start a second application that tries to create a mutex with the same name, the second application will fail.
in the example of the link i posted you should see how to do it.
|
|
|
|
|
Thank you for your reply, m@u.
If an application window was closed, but the process is still running due to the application software probelm(I encountered such application programs), and I start the same application again, or I start another application using a same library, will the mutex make the application fail?
I still do not know how to use mutex. I shall study how to use it.
lk
|
|
|
|
|
That's good to know! Thanks,
Jeff
|
|
|
|
|
This sounds like it will be significantly more tricky than you would like. The biggest problem is if an application using the DLL crashes, or if that application is killed by the OS. Then it will not be signaled that the resource has been freed, and then NOBODY could use the extended functionality of the DLL. The only way I see this working is if you send a process handle every time you instantiate the dll. Then, when an instance of that dll is requested, you check to see if any of the processes you THINK are using the DLL are still running, and, if you find some that are not, then you would remove those from the list. This can still fail if it happens that one of your processes died, and some new process started that was assigned the same process handle, so you may also want to check the process name, class, etc.
In addition to all the work mentioned above, since the static variables are apparently not being persisted, you would have to either store all that information in the system registry or on the file system elsewhere, and use some other method of thread synchronization (because there would be no common code-based objects, you could not simply lock a static variable like usual).
If you don't care about the exception conditions, then just increment and decrement a counter in the system registry every time you run the constructor and destructor for your dll class, respectively (again, synchronization is required).
I can't personally think of a better (simpler) way to do this, but if you come up with something, let us all know.
Jeff
|
|
|
|
|
Thank you for your reply.
I had thought about using windows regitery or file system elsewhere, but I have to give it up, because NOBODY can use the library if something happen and the library is not released, such as suddenly power off, or the application is killed by OS.
So I am seeking a way to have a running record at runtime.
lk
|
|
|
|
|
Actually, what you want to do can be done quite easily if you know the trick. As you have found out by now, you can't actually have a singleton DLL because it runs in the process space of the calling application and is isolated from other instances of itself. So, to achieve this you would host this DLL in a remotable object which uses the WellKnown type of Singleton.
This[^] article should help you.
|
|
|
|
|
Thank you, pete. I will study and try it.
lk
|
|
|
|
|
I have a checked listview on my windows form. When the form loads I have code where a specific item in the listview is selected:
listView1.Items[1].Selected = true;
But I also have a selected index changed event. In this event I go through all listview items and set their checked property to false and then check the item that has just been selected:
foreach (ListViewItem lvi in listView1.Items)
{ lvi.Checked = false; }
listView1.SelectedItems[0].Checked = true;
These two pieces of code do not work together. If I comment one section of code, then no errors occur and vis versa but when both pieces of code are not commented out I get the following error at run time:
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
How do I solve my problem as both pieces of code are needed.
Lucy
|
|
|
|
|
How about only assigning the SelectedIndexChanged event after making the initial item selected.
|
|
|
|
|
So the SelectIndexChanged event would fire when the user selects an item? How would I do that?
Lucy
|
|
|
|
|
Lucy_H85 wrote: checked listview
Haven't heard of it. Is it a ListView with CheckBoxes or CheckedListBox?
I will use Google before asking dumb questions
|
|
|
|
|
It is a listview with checkboxes.
Lucy
|
|
|
|
|
Well....I will just give you an idea. The StackOverflow exception is because in the CheckChanged event you change the checked property of the listview items, thus this generating another checkchanged event, and so you enter in a infinite loop, which at a certain moment fills the system's stack and the program stops. To avoid this situation you should check if the checkedchanged event has been triggered by the user or by your code. I situation almost like these I used to use a boolean value which is set to true if I change the checked property of an item, or false if the user checks the item, and in the event handler method do whatever you need depending on the value. It's just an idea to work around this problem...maybe you'll find another one.
Hope it helps.
I will use Google before asking dumb questions
|
|
|
|
|
Thank you for your help. Yes I noticed that both of these events were fired many times whilst debugging. I now understand a bit more about stacks. I will try and use boolean values to solve my problem.
Lucy
|
|
|
|
|
I manage to play video in panel in c#. Now i want to play another video automically when the panel is idle(like screensaver). How can i determine that the panel is idle?and then i want to play another video. Please help me with this problem
|
|
|
|
|
You might want to play the other video when the previously running video is no longer running. I'm sure there must be something that determines if the stream is at an end.
What are you using? WMP?
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
"There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib
"Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"
|
|
|
|
|
No i am not using windows media player. It is directly running on panel.Do u know anything that determine video is stop.
|
|
|
|