|
Cheers guys.
I am in the process of removing any sections where i have interfered with the GC. There are a couple of operations that seem to make a significant difference to the RAM so i will leave them for the time being until i get round to resolving them.
I take it, its safe to use the dispose methods of third party wrappers i.e. DirectX meshes and so forth?
Thanks again
|
|
|
|
|
R4jlu wrote: I take it, its safe to use the dispose methods of third party wrappers i.e.
DirectX meshes and so forth?
Safe - and probably necessary. If they've provided them, they've provided them for a reason.
|
|
|
|
|
As has been hinted at above, you've got the dependency backwards with that event handler. If a CompileFinalCell is a temporary thing owned by the form, if possible the calls should all go from form to compiler:
public partial class Form1 : Form
{
private CompileFinalCell finalCellCompiler;
private void twoDDisplay_Click(object sender, EventArgs e)
{
finalCellCompiler = new CompileFinalCell(this,
fibrePositionGenerator, unitCellData.outerCellSize,
finalBeamForce, finalShellForce);
}
private void DepositNextHandler(object sender, EventArgs e) {
if(finalCellCompiler != null) finalCellCompiler.DepositNext();
}
private void Clear()
{
if (finalCellCompiler != null)
{
finalCellCompiler = null;
}
}
}
class CompileFinalCell
{
public CompileFinalCell(FibrePositionGenerator fibreData, SizeF outerCell,
ForceDirectedAlgorithm beamForce,
ForceDirectedAlgorithm shellForce)
{
}
public void DepositNext()
{ MessageBox.Show("Button clicked"); }
}
You don't need to implement IDisposable on something which has only managed references, as a general rule (it's designed for releasing system level things like file handles, graphics objects, fonts etc which are limited in number and it's important that you clean up quickly).
Edit: oh yes, don't forget to hook up that button click handler in the form's designer.
This also has the (major) benefit that the final cell compiler is now independent of the UI, i.e. you could create it in a background thread, from network input, as a scheduled service etc without having to change the code.
If the compiler needs to communicate back the other way, you should give it events which the form can then hook onto.
|
|
|
|
|
Hi there,
I am working on a project in C#. I have a problem rearranging my controls on form when I click the maximize button of my form. I mean whatever the positions I have placed my controls on form, they remain on the same position even if I am going to maximize the form. I want to solve this problem so that whenever I maximize my form the controls should rearrange appropriately. Any help in this regard will be hightly appreciated. Thanks.
|
|
|
|
|
Use the Dock[^] and Anchor[^] properties of the child controls.
This[^] article may also be helpful.
|
|
|
|
|
Thanks Shameel for your help. I have already tried Anchor and Dock properties of the individual controls but they are not solving my problem. What I really need to know is that whenever I resize the form during run time, all my controls should be on the same locations with an increase or decrease of their propotional widths and heights, so the look and feel of the form should not be affected. Is there any way to do that? Thanks.
|
|
|
|
|
You generally don't want to do that, as a lot of controls (basically anything which includes text) aren't designed to be resized in such a fashion.
|
|
|
|
|
How do you get an Idle Message in a UserControl class in C# / Silverlight?
|
|
|
|
|
hi everyone
i need to get the Url of a frame from IE or another browser but i don't know how xD
in this moment, i can find url in the address bar using DDE service DDe to get url from browsers
so please if any one have an answer about getting the frame's url it would be so nice
thanks
|
|
|
|
|
I want a code for retrieving HDD serial number in C#,can you please help me?
|
|
|
|
|
|
There is no single method for getting a hard drive serial number. WMI does not work in all cases because the is no mandate that says every manufacturer has to support it.
There are about 4 different methods for getting a hard drive serial number. None of them work on all hard drives. It's best to use multiple methods to be sure your actually getting the correct information.
There are libraries out there that will do this for you, such as this one[^]. I haven't used it though, nor any other library for this.
|
|
|
|
|
Adding to what others have said, on Vista and later you may get UAC trouble, as getting physical information is considered dangerous. Having some kind of solution that works on XP is no guarantee it will work on more recent Windows versions.
|
|
|
|
|
Hi,
suppose my SP returns 8 results sets i want to fetch only the 8th resultset....the issue which im facing with IMultipleResults.GetResult<> is
it is not able to give the 8th resultset...and i need to call all the 7 resultsets before i call 8th resultset....and please let me know how to fetch the 8th resultset directly....
As this is possible in classic ado.net using tablemapping to fetch the desired result set ...please let me know how this can be achieved using Linq to Sql..
|
|
|
|
|
siva455 wrote: please let me know how this can be achieved using Linq to Sql.
Maybe by posting in the LINQ forum.
|
|
|
|
|
I'd recommend rewriting your SP so it only returns the information needed.
Since you're returning 8 results set and throwing out 7 of them, you're wasting compute resources on the SQL Server.
|
|
|
|
|
Thanks for ur solution...but as my SP used across other places of code where they coonsume some of the
resultsets in 8 resultsets....
Please suggest me is there a way to fetch only the particukar resultset from SP...
|
|
|
|
|
Then write another SP that only returns the resultset in question.
Having a single SP that returns all kinds of data your don't need is very wasteful.
Or dont use an SP and just code the SELECT string to return the data required.
|
|
|
|
|
|
I am not able to access the crystal reports at run time using C# GUI. I am running the application in Windows 7. Evrything is ok bt while running, it is giving error in the statement where crystal report is initialized. Do we require some component to be installed there???
NEHA GUPTA
|
|
|
|
|
Since you didn't think the error message was all that important to post, we can only guess.
Yes, you have to install the CrystalReports runtime in order to run your app that uses CR. It must be the same version as what you wrote your app against.
|
|
|
|
|
I'm trying to understand how to use the P/Invoke method SystemParametersInfo() to get some information from my mobile computer. I am ok with the following requirements:
using System.Runtime.InteropServices;
[DllImport("coredll.dll")]
private static extern int SystemParametersInfo(uint uiAction, uint uiParam, StringBuilder pvParam, uint fWiniIni);
with a question regarding the 'pvParam' parameter. I have seen it used as StringBuilder, string, int, etc. If I type it as a string, does that limit the types of uiActions and uiParams I can return? Do I have to re-construct it with a different type for the 'pvParam' for others? I apologize that this is a bit confusing, but the document on MSDN shows the constructor and the parameters, but it's difficult to figure out exactly how to use it from that. My final source of confusion, and this is the one I'm really hung up on, is why I have to perform the following:
private const uint SPI_GETPLATFORMTYPE = 257;
private const uint SPI_GETOEMINFO = 258;
I don't understand why I have to specify an int value, and does the value matter? I see that it happens to be the next two values after 256, which seems significant but I'm not sure why. I can't find any documentation that shows that this is what I must do in order to use something like SPI_GETOEMINFO, nor can I find an explanation for the use of '258'.
Regards,
Scott
|
|
|
|
|
The reason for the StringBuider is so that the called method can modify it - strings are immutable in .NET so when a change is to be made a new string is created. This is not the case with StringBuider. If you pass string to the P/Invoked method, it cannot change it.
pvParam just stands for "pointer to a void" parameter, which is the C++ version of a reference to an object - it is a parameter which can be in effect any type, depending on what function the method is to perform on it.
Why an int value? Because the constant is an integer! C# is strongly typed, so if you didn't specify the type when you declared it, it could cause confusion when you used it later.
Yes, the value does matter! It is the value that is passed through to the P/Invoked method, and which tells it what action it is to perform - not the name of the constant! If the value is wrong, the method will perform the wrong action. You don't need to declare these as constants - you could just use the numbers directly in the method call - but it is a lot, lot more readable and checkable to use the same names and values that the called method does. (We can't use the same definition file, because they are stored in a ".h" file for the C++ and C# cannot understand those. However, what most people do is to read the ".h" file in a text editor, and automaticlly replace
#define SPI_GETPLATFORMTYPE 257 with
private const uint SPI_GETPLATFORMTYPE = 257; to make sure they are the same throughout! I know I do...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
That helps a great deal! This is the kind of stuff that I just can't seem to find in books. I figured the integers had a specific meaning, and that they weren't just randomly chosen. Thanks for providing me with the insight as to where they come from. Where could I find the C++ header to review?
|
|
|
|
|
Sorry - in this case I can't help: I've never needed SPI_GETPLATFORMTYPE!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|