|
hello,
yes i will look for this in the SDK.
But my biggest problem i still have is the Delegate-Callback mechanism? I do not simply understand how this mechanism functions, respectively in your sample code.
I read the things to delegates and TimerCallback in the MSDN and looked at the samples but i did not understand how this exactly goes?
That is for sure still my biggest problem... I do not find the logic in this mechanism..i hope i express me the right way...
yours sincerely,
patrick
|
|
|
|
|
As I've said several times, a delegate is a managed function pointer. This allows you to pass a method as a parameter and execute it without knowledge of the actual method that needs to be executed. Just like with the EnumWindows API - in native code you pass a function pointer. In .NET, you pass a delegate (a function pointer managed by the CLR). See the Delegate class in the .NET Framework SDK for more details.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
yes i know defintion of the delegate, but the thoughts behind why you build up this sample in that way is not clear.
You have explicit the EnumWindowsProc-delegate but you have not explicit declare the TimerCallback-delegate?
And why do we need the evt.WaitOne(); after the creation of the Timer-object? - the AutoResetEvent evt is already set to false.
yours sincerely,
patrick
|
|
|
|
|
The TimerCallback is a delegate that's already declared in the .NET Framework and the .NET CF. Why would I declare it? You don't re-declare the TimerCallback , you instantiate it with reference to a method that you must define. That's a delegate.
Why do I call AutoResetEvent.WaitOne ? Because the Main method has to block until signalled otherwise the application will terminate immediately since the Timer was started on a different thread. That certainly is not what you want.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
okay that's clear.
You said the main-method and the TimerCallback-method run in different threads. How is it distinguished that the TimerCallback runs in a different thread? - when it would not run in a different thread i wouldn't need the evt.WaitOne()? - because the execution of the class goes only forward when the TimerCallback-method runs through and calls the EnumWindowsCallback and so on?
yours sincerely,
patrick
|
|
|
|
|
...and do you know any further method besides the record of the titles of the open windows that i can log to get more detailed information about what do user do or which commands he executes?
Thanks in advance.
Yours sincerely,
patrick
|
|
|
|
|
hello,
i have now a little application which writes the title of the active window in a xml-file, but when i want to deploy it with the Emulator there will occur the following exception and i do simply not know why this error occurs??
A managed MissingMethodException
occured at
Test:TimerCallback+0x25
Test:TimerCallback+0x25
Timer:ring+0x59
Ok to terminate.
Can somebody please tell me what went wrong?
thanks in advance.
regards
patrick
|
|
|
|
|
I looked in the MSDN for some helpful topics but i only found "An Introduction to P/Invoke and Marshaling on the Microsoft .NET Compact Framework". I do not know, if this topic helps me..but i don't think so.
Without any example code it is very difficult for me to realize your idea with the EnumWindows, Timer-Class, etc, because i do not work yet with this classes (EnumWindows,etc.), regardless of array lists and hashtables.
Have you got further tipps or hints?
thanks in advance.
yours sincerely,
patrick
|
|
|
|
|
If you look at the code I gave, I already showed you how to P/Invoke EnumWindows and how to declare the EnumWindowsProc delegate (what you name it doesn't matter, though). For the various Timer classes, look in the .NET Framework SDK (it's installed locally if you took the default installation for VS.NET: just type "Timer class" in the index and check to make sure at the bottom of the page that they support the .NET CF). They should all have examples of use.
Being given the answer won't teach you everything. The hardest part of this solution is the P/Invoke, which I already gave you code for earlier.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hello,
i have some problems with the NSpring Framework. I want to use this framework to log in a file, which events occurs in a ASP.NET Application. But i do not really know how i can use this framework and how to start with it.
The situation is as follows: i developed a ASP.NET Application for a PDA and now i want to change the code in that way that it would be logged in a file on the PDA what actions a user execute (which events would be execute, which method, at what time,..).
Can anybody help me with this problem?
thanks in advance.
yours sincerely
patrick
A Comprehensive Logging Package for .NET
|
|
|
|
|
If you have specific problems with an application/library, you should ask the authors and/or their support contacts. Since NSpring is hosted on SourceForge, there are a couple differnet forums you can use.
If you have questions specific to C#, this is the place to ask.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hello,
oh i thought i can post it here because the framework is also explained on this site. on the www.SourceForge.net page i didn't find a forum where i can post my question??
yours sincerely
patrick
|
|
|
|
|
No, the ".NET Framework" is discussed on this site, not the "NSpring Framework". Specifically, this forum is for discussions about C#, one of many languages that target the CLR (part of the .NET Framework).
If there is an article you found on this site that discusses NSpring, then you should ask this question on that articles message board at the bottom of the page; that's what it's there for.
If you go to the SourceForge project page and look, you'll see a Support[^] link.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
hello,
i already post my question on the forum of jeff, but he did not answer.
yours sincerely
patrick
|
|
|
|
|
i am using a lot of bitmap objects in my application , when i get to over a 100 objects with bitmaps my application slows and eventualy crashes, how can i handle the memory problem ? is there a better way to save images than with bitmaps?
|
|
|
|
|
blankg wrote:
is there a better way to save images than with bitmaps?
When you are done with the Bitmap call Dispose() . Another option is to use the C# using keyword so that appropriate try/finally blocks are emmited and then your Bitmap object will be cast to an IDisposable and Dispose() will be called automagically for you.
using (Bitmap b = new Bitmap("C:\..."))
{
}
- Nick Parker My Blog | My Articles
|
|
|
|
|
For any object that implements IDisposable , you should always dispose of the object when finished. This includes (and definitely is not limited to) Bitmap and Graphics . In C#, you can use the using statement to make sure that objects are disposed even in case an exception is thrown:
using (Bitmap bmp = new Bitmap(32, 32))
{
using (Graphics g = Graphics.FromImage(bmp))
{
}
bmp.Save(...);
} This ensures that unmanaged resource (resources that aren't managed by the CLR, like native handles) are freed and that managed objects are disposed of immediately instead of the next time the GC (garbage collector) is run by the CLR.
On a note, if you call Environment.Exit finalizers (like destructors in C++...sort of) are executed but IDisposable.Dispose is not. This really isn't too important since Environment.Exit will unload the CLR and exit the host process - the OS will free all handles in use at this time. If any exceptions are thrown or you return execution to the caller, using the using statement will still dispose the object. The following is equivalent:
using (Bitmap bmp = new Bitmap(32, 32))
{
}
Bitmap bmp = new Bitmap(32, 32);
try
{
}
finally
{
bmp.Dispose();
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi all ,
As part of my preparation for an upcoming presentation on .NET reflection API
at the next Cochin .NET user group meeting , i have created a small four function
calculator [ + , - , / , * , ( . ) , unary + , unary - , numbers ] which can evaluate
arbitary mathematical expressions.
Aim of the code is just to show how one can use Reflection.Emit code to
create an assembly on the fly.
u may download a zipped PDF file from the following url
http://www.praseedpai.com/Misc/misc.html
I hope this will give an overview to a novice developer on IL code generation
Here is how u can use the code
----------------------------------------
Copy the contents of the PDF document on to a text file ( Expr.cs ).
use C# command line compiler csc to compile the code as follows
csc Expr.cs
u may execute the program like this
Expr "2*3"
Expr "-2+3*4"
Praseed Pai
P.S :- All the numbers are treated as doubles . No decimal points are allowed in
numbers .
|
|
|
|
|
I would suggest that you write up an article covering the material in your presentation. There are too many questions that get asked in this forum, your thread will quickly disappear.
- Nick Parker My Blog | My Articles
|
|
|
|
|
Hi,
I've designed 2 custom controls (ColorButton & ColorRadioButton) that subclass off the original windows controls, but are composed of 3 images each (left cap, right cap, center slice). I need to build a set of subclasses of these buttons (ie OrangeButton,
GreenButton,...) which are identical to the parent except the bitmaps (which I have set up as properties) would be distinct. This works fine, but I don't want my base classes (ie ColorButton) to be visible in the Design view (from the toolbox). I tried making the base class protected, but that won't compile. How can I restrict one class in a dll from the toolbox while allowing the derived classes to show up?
thanks!
Deanna
|
|
|
|
|
there is an attribute you can apply to your components that will prevent it from being able to show and select into the toolbox, what it is called i cannot remember look in system.componentmold.design perhaps.
top secret xacc-ide 0.0.1
|
|
|
|
|
Actually, there are a few and they are in the System.ComponentModel namespace.
Those are BrowsableAttribute , EditorBrowsableAttribute , DesignTimeVisibleAttribute , and DesignerSerializationAttribute (a little less like the others, but can hide the code from the code serializer).
I'm not sure if these will help, though. Customizing the toolbox in VS.NET reflects the .NET assembly you opened and looks for Control derivatives. Whether or not that code makes use of the attributes mentioned above is questionable (only giving it a try would determine such behavior).
Another attribute that may work (though I've never used it) is the ToolboxItemFilterAttribute . This would at least make the toolbox item hidden if the filter string was specified to never match anything. I doubt this would prevent the control from showing up in the toolbox customization dialog, though.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Hy everyone!
I do want to generalize some comparestatements or assignstatments in my C# proggy. I managed to do so when I had a sender object (casting it) but now there is none and I am stuck.
My datastructure looks like this:
ldata contains the data
this looks like this
ldata[]
||=> keys[]
|| ||=> keyID //id of the field to display the data in
|| ||=> telnumber //the data to being displayed
||=> telefonID //the telefonnumber for which to display data
the telefonID should not matter, you can switch the numbers but only one of those is displayed at once, meaning you select one and the data for this number is displayed. But this doesn't matter concering my problem because at this stage the number has already been selected and I do just have to display the data for the selected number or check for changes before either switching numbers or just to save them.
My code looks like this at the moment:
for(li=0;li<ldata[0].keys.Length;li++)<br />
{<br />
if(ldata[0].keys[li].keyId==1)<br />
{<br />
txtNameKey01.Text=ldata[0].keys[li].telephoneNo;<br />
}<br />
}<br />
<br />
for(li=0;li<lTelephone[0].keys.Length;li++)<br />
{<br />
if (lTelephone[0].keys[li].keyId==1)<br />
{<br />
if (lTelephone[0].keys[li].telephoneNo!=txtNameKey01.Text)<br />
}<br />
}
But well this isn't nice and even harder to change lets say to 24 TextBoxes, but well it works . What I do want to do now is change the thing above to something like
for(li=0;li<ldata[0].keys.Length;li++)<br />
{<br />
TextBox=ldata[0].keys[li].telnumber;<br />
}
The pseudocode above and beneeth should describe what I want to do. I do want to create a general object/variable/... whatever to just having to assign or compare in one statement. I do want the keyID to describe where the data should be sent to or which fielddata should be compared to.
With strings you are able to copy parts together like "hello"+"world"+year.ToString() => hello world 2004 but this doesn't work with assignments, does it?
for(li=0;li<lTelephone[0].keys.Length;li++)<br />
{<br />
if (lTelephone[0].keys[li].telephoneNo!=TextBox.Text)<br />
}
in the pseudocode above once again it should be using the keyID to decide which TextBox I am really doing the comparison with.
But at the moment I do wonder if this is really possible or if I have to live with this if-statements and with tons of code for comparison and assignments!
Thanks!
Stephan.
|
|
|
|