|
Hi.
I'm facing very frustrated problam.
The code is little long so i'll try to describe:
1. I have object (entity) called MyObj , and one of it's members is array of 'int' type, and called "intArr".
2. Collection List<MyObj> .
3. DAL project to manage the list.
4. In the 'main' class i have variable which is also array of 'int' type, and called "intArr".
this variable passed as parameter to function in the DAL project, to create new "MyObj" and add it to the List.
The problam:
When the variable "intArr" in the main changed, it's effected immidiately on the MyObj.intArr.
I thought that both, reference to the same 'intArr'. possible?
|
|
|
|
|
Yes, this is the reason: an array of int is treated as an object and is assigned "by reference".
If what you what is a "deep copy" of the array you should code it explicitly.
class MyObj
{
...
public void DoSomething(int [] intArr)
{
this.intArr = intArr.Clone();
}
...
}
|
|
|
|
|
Thanks. It helps.
Just needed "casting" as int
class MyObj
{
...
public void DoSomething(int [] intArr)
{
this.intArr = intArr.Clone() as int[];
}
...
}
Quote Selected Text
|
|
|
|
|
I have a program that is running on a kiosk. I'm using the Shockwave dll to play flash files. It appears as if the more complex the flash file is (more action script) there's a memory leak until eventually the program crashes. This program has the flash player on the screen and loads file after file without closing down. So if it's not really releasing all of the memory, which is what it appears to be doing, how can I clear out the memory?
If need be what I would do is after playing a file, I would destroy the object, cleanup the memory and then create a new one.
In looking around the web, I have not yet been able to find how to destroy the object, clean up the memory and then recreate the object.
Can somebody please help?
Thanks.
Jeff.
|
|
|
|
|
Effectively, have 2 instances running - when one is finished with unload it and load a new instance in a new app domain and show the background instance in place.
|
|
|
|
|
I don't understand what you mean by unload it and load a new instance. Do you mean unload the whole program? There is other stuff going on on the screen. The flash player is only part of what is visible on the screen.
Jeff.
|
|
|
|
|
No - I was thinking you'd have the Flash part in a separate AppDomain - you could overlay this over the top by controlling the Z Order. Release the App Domain, and reclaim the memory.
|
|
|
|
|
What do you mean by AppDomain?
BTW - don't know if it matters this is a Windows App.
J.
|
|
|
|
|
Are you using .NET (you should be if you are posting in the C# forum)? Look up Application Domains.
|
|
|
|
|
Pete,
I'm still trying to solve this. I'm using C# .Net 1.1 (Don't ask!) on a Windows App.
Any help would be greatly appreciated.
Jeff.
|
|
|
|
|
Hi!,
where do I configure the option that my windows service can be suspended and continued and not only started and stopped ?
(I meen that the options are shown and selectable in the service list menue).
Is it a code option or a setup option ?
Thanks
Frank
|
|
|
|
|
I haven't had a need to do that and I can't imagine needing it. Why do you want to do it?
|
|
|
|
|
Hi,
that's not the question. If you examine the service list you will find some services which have these options and some have not.
In my case it make sense to suspend the service do something with the data and after this to continue the service.
So, please where is the option to be set ?
Thanks
Frank
|
|
|
|
|
But why not just stop and start?
|
|
|
|
|
PIEBALDconsult wrote: Why do you want to do it?
Possibly to allow existing processing to terminate cleanly, and prevent some new processing, while still running other background processing.
|
|
|
|
|
Electron Shepherd wrote: allow existing processing to terminate cleanly
Stop should do that as well.
Electron Shepherd wrote: while still running other background processing.
Then it's not paused, is it?
Electron Shepherd wrote: other background processing
Possibly should be in its own Service.
|
|
|
|
|
A good example would be a web server implementing Keep-Alive. You may need to prevent new inbound connections, possibly for load balancing or other resource allocation requirements, but preserve the internal state data.
Dont forget that just because you've never needed to do it doesn't mean no-one ever needs to do it.
|
|
|
|
|
Electron Shepherd wrote: A good example would be a web server implementing Keep-Alive. You may need to prevent new inbound connections, possibly for load balancing or other resource allocation requirements, but preserve the internal state data.
And you are suggesting that you would not do that when stopping as well?
Electron Shepherd wrote: Dont forget that just because you've never needed to do it doesn't mean no-one ever needs to do it.
Don't forget that just because someone wants to do something it means that it is a good idea. Or even that it will solve their real problem.
|
|
|
|
|
jschell wrote: And you are suggesting that you would not do that when stopping as well?
Yes, becuase in my specific example, the internal state is related to a TCP connection, so maintaining and restoring the state across a stop / start event is meaninglesss.
jschell wrote: Don't forget that just because someone wants to do something it means that it is a good idea.
True. My reply was directed at the person who said (very unhelpfully in my opinion)
"I haven't had a need to do that and I can't imagine needing it."
|
|
|
|
|
I believe ServiceBase has a property called CanPauseAndContinue . Set it to true and then override the OnPause and OnContinue methods.
|
|
|
|
|
Hi Calla,
that sounds good.
Thanks
Frank
|
|
|
|
|
You're welcome!
|
|
|
|
|
Hi all developers.
Lately I started working on a library that allows to compose complex asynchronous operations from simple ones using LINQ syntax and extension methods. It can be found here. The idea itself was taken from F# asynchronous workflows, so I don't take any credit for the idea, just for the implementation.
The need occurred when I was working for a company that had an existing server that provided a known set of operations and we needed to write a UI client that the operations it wanted to perform were composition (sequential or parallel) of the server's operations. So instead of writing the ugly code with callbacks and exception handling we came up with this idea.
Here is a simple example for the library's usage:
Async<DataItem[]> operation =
from dataItems1 in provider1.AsyncGetDataItems("data items id")
from dataItems2 in provider2.AsyncGetDataItems(dataItems1)
select dataItems1.Concat(dataItems2).ToArray();
operation.Execute(CompletionCallback);
I would like you to try and and send me any feedback about the design/implementation and of course bug reports.
Thanks!
Alex.
P.S. I Googled it and found out that something already blogged about it. So other people came up with this idea too. I just didn't find a ready-to-use library that people can download and start using, so I decided to write one.
|
|
|
|
|
I want that check box in a datagridview should act like a radio button.Means whenever I select a checkbox it will be selected and rest of all would be deselect.
I have used cellContentClick event of the datagrid view.Structure of the datagridview is like-
1st column is checkbox and 2nd is text box.following is the code i have used-
for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
if (i == e.RowIndex)
{
dataGridView1.Rows[i].Cells[0].Value = true;
}
else
{
dataGridView1.Rows[i].Cells[0].Value = false;
}
}
The above code runs good when i select another checkbox.But when one checkbox is selected/checked and now I again click on the same checkbox then it is deselected/unchecked.I want when the same checkbox is checked again it won't unchecked and remian checked.
How can I do this?
Thanks in adv....
|
|
|
|
|
If you must use checkboxes and not radiobuttons, then you could add something like the following to your call. You will of course want to add some better validation.
for( int i = 0; i < dataGridView1.Rows.Count; i++ )
{
CheckBox ctl = (CheckBox)dataGridView1.Rows[i].FindControl( "CheckBoxControlName" );
if( ctl != null )
{
ctl.Checked = ( i == e.RowIndex );
ctl.Enabled = !( i == e.RowIndex );
}
}
This would simply disable the currently selected checkbox while allowing any other to be selected.
(NOTE: I just hammered this out in the editor. If I have a syntax error or typo... sorry.)
modified on Wednesday, October 13, 2010 2:50 PM
|
|
|
|