|
|
A delegate is similar to a function pointer:
delegate void MyDelegateType(int i);
void SomeFunction(int hello);
// Declare a function-pointer
MyDelegateType funcPtr = new MyDelegateType(SomeFunction);
// Call the function
funcPtr(5);
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: The Secular Left, the Religious Right, and Prejudice
Judah Himango
|
|
|
|
|
Thank you, this did the job!
P.S. Munch is cute
C++ libraries at a give-away price on www.neatcpp.com: TWAIN, DirectShow, Interprocess Communications, etc...
|
|
|
|
|
|
Is it possible to get incomming information from the serial port using the Net Frameworks v1.1 ?
Can anyone help me with this?
Thanx
|
|
|
|
|
This[^] should just about cover it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hey!
I am using the following code in a event(SerialPort.RecivedData event) that fires whenever data is written to a stream(serialPort)
<br />
if (RUNNING)<br />
{<br />
ThreadPool.QueueUserWorkItem(new WaitCallback(onDataReceived));<br />
currentRunningThreads++;<br />
}<br />
in OnDatareceived the serialPort is used to read the existing data.
Now i need to close this serialPort, but i get errors without any source to show?
I am setting Running to false, but that is not solving it?
How can a see when the ThreadPools threads realy is finish with theres jobb?
Best Regards
Snowjim
|
|
|
|
|
A more Specified error message:
First a MessageBox that says that there is no source code to be displayed.
Then a smaller box appers
Title: ObjectDisposedException was unhandled
safe handler has been closed
I do have try and catch on every method i have but this exception is never runned(if it would i could see where the error is appering in my code)
|
|
|
|
|
One solution would be to create an event CloseSerialPort and call it from the onDataReceived method when it has finished it's job. Then you could put all the code needed to close your serial port in the event handler.
I reject your reality and substitute my own!
- Adam Savage, Mythbuster
-George W Bush
life is like a roll of toilet paper. The closer it gets to the end, the faster it goes.
|
|
|
|
|
How do i know when to call this CloseSerialPort in onDataReceived method?
consider this:
SerialPort.RecievedData event is triggerd
Job is added to the threadpool that points to the onDataReveived method
SerialPort.RecievedData event is triggerds 5 times and diffrent threads are working there way thow onDataReceived that contains a look part.
By this i will not know what thread that is the last one.
I need to close this threads before i can call serialport.close();
|
|
|
|
|
Instead of directly using ThreadPool, you can try wrapping OnDataReceived in a delegate and calling BeginInvoke on the delegate. That'll allow you to pass a callback that'll get called once OnDataReceived completes. Even otherwise, BeginInvoke returns an IAsyncResult that has a bool property IsCompleted that you can query to find out if the method has completed.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hello,
I have a question regarding inserting and repositioning XML nodes... I need to insert a new node and move the existing 'grandchildren' nodes to be under the newly inserted node. Basically, I have an xml doc that looks like this:
<root>
<child1 Id="">
<grandchild1>text1</grandchild1>
<grandchild2>text2</grandchild2>
<grandchild3>text3</grandchild3>
<grandchild4>text4</grandchild4>
<grandchild5>text5</grandchild5>
<grandchild6>text6</grandchild6>
<grandchild7>text7</grandchild7>
</child1>
<child2 Id="1">
<grandchild1>text1</grandchild1>
<grandchild2>text2</grandchild2>
<grandchild3>text3</grandchild3>
<grandchild4>text4</grandchild4>
<grandchild5>text5</grandchild5>
<grandchild6>text6</grandchild6>
<grandchild7>text7</grandchild7>
</child2>
<child3 Id="2">
<grandchild1>text1</grandchild1>
<grandchild2>text2</grandchild2>
<grandchild3>text3</grandchild3>
<grandchild4>text4</grandchild4>
<grandchild5>text5</grandchild5>
<grandchild6>text6</grandchild6>
<grandchild7>text7</grandchild7>
</child3>
</root>
And I would like to load this existing file using C# .NET, then end up with the XML doc to look like this (see below).
<root>
<child1 Id="">
<newnode1>
<grandchild1>text1</grandchild1>
<grandchild2>text2</grandchild2>
<grandchild3>text3</grandchild3>
<grandchild4>text4</grandchild4>
<grandchild5>text5</grandchild5>
<grandchild6>text6</grandchild6>
<grandchild7>text7</grandchild7>
<newnode1>
</child1>
<child2 Id="1">
<newnode2>
<grandchild1>text1</grandchild1>
<grandchild2>text2</grandchild2>
<grandchild3>text3</grandchild3>
<grandchild4>text4</grandchild4>
<grandchild5>text5</grandchild5>
<grandchild6>text6</grandchild6>
<grandchild7>text7</grandchild7>
<newnode2>
</child2>
<child3 Id="2">
<newnode3>
<grandchild1>text1</grandchild1>
<grandchild2>text2</grandchild2>
<grandchild3>text3</grandchild3>
<grandchild4>text4</grandchild4>
<grandchild5>text5</grandchild5>
<grandchild6>text6</grandchild6>
<grandchild7>text7</grandchild7>
<newnode3>
</child3>
</root>
See where the 'newnode' is inserted and the existing 'grandchild' nodes are now located under the 'newnode'. Would a for loop be the most efficient here... where I can set it up to look for all the 'child' nodes and loop through to insert the 'newnode' and reposition it's 'grandchild' nodes? I'm trying to keep my code very simple here without trying to add in any extra namespaces or classes.
Any advise would be most appreciated! Thanks in advance...
|
|
|
|
|
|
Thanks Marc! Yea, that's how I have it currently (load in the xml and write it out to another xmldoc by using the create, appends and prepend methods), but it just seems a bit clunky to me. I'll take a look at your article...
|
|
|
|
|
I'm in the process of writing a program that has many MDI children to it. Some of the functions for each child are the same, such as close and print. Where I have the problem is getting a print option to work correctly.
I've looked at creating a File -> Print menu option in the MDI parent but I can't figure out how to get that to point to a proceedure in the MDI child (with the though that each child would have a proceedure with that name.) I can't figure out how to do this though.
The other option I looked at was to make a MainMenu on the parent with some items, and then have child-related item in a MainMenu item on the child form. The problem I am having with this approach is that I have File -> Close on the parent and when I try to add a File -> Print on the child, it creates two file menus. I've tried every combination of MergeType and MergeOrder I can think of in both the parent and child menus.
Is there something simple that I'm missing. I would think what I'm trying to accomplish here is pretty common. Any help would be greatly appreciated.
--In a world without fences, who needs Gates?
|
|
|
|
|
SignMan359 wrote:
I've looked at creating a File -> Print menu option in the MDI parent but I can't figure out how to get that to point to a proceedure in the MDI child (with the though that each child would have a proceedure with that name.) I can't figure out how to do this though.
I think that you are overcomplicating it. You don't need to implement a print method in every child window. You need to implement your print method in the MDI Parent code and have it print only the contents of the active child window (which ever child window has the focus).
|
|
|
|
|
Don't worry about all the menu merging and stuff. Just put a Print item in the File menu. In it's Click handler, you reference the active MDI child window by using the ActiveMdiChild property of the MDI Parent window, where your menu is. All you need to do to call the Print method of your child form is:
Form myChildForm = this.ActiveMdiChild;
myChildForm.Print();
This will call the Print method on whatever child form currently has the focus.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have an application that consists of a main windows form and a 2nd thread that handles communications back to a server. Based on a command stream from the server the main thread starts other windows forms that share an event/notification message structure.
Since each of the newly created windows forms totally control the UI and handle messages related to the tool passed through the event system I wanted to run each on an independent UI thread instead of having all windows running off of the single main UI thread.
In playing around with this I have not found any examples and have been unsuccesful at trying to figure out a structure that would do what I'm trying to accomplish.
Any suggestions or pointers.
Thanks
Neil Lamka
neil@meetingworks.com
|
|
|
|
|
This will do the trick
void UIThread()
{
Form yourForm = new Form();
Application.Run(yourForm);
}
}
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thanks much, I'll give that a try.
Neil Lamka
neil@meetingworks.com
|
|
|
|
|
hi.what I asked to do is editing image with .net like user uploads an image-for example his photo..then he wants to make his eye color green.he selects green and posts code..on the server my code finds eye and changes its color.[*-)] I hope you guys can understand that..can I do this with Image class or another one?any examples or links would be great if possible.thanks..
|
|
|
|
|
I might be misunderstanding you but try looking at examples that put a watermark on images. A lot of websites use this technique to create their logo on images that users upload to their website. Pretty much what happens is that the image usually doesn't get altered but when the image gets rendered on the webpage text (or a logo) is superimposed onto the image. Check out this link: This will show you how to create a quick and dirty way to brand your images using ASP and GDI.
http://labs.insert-title.com/labs/article832.aspx
|
|
|
|
|
thanks..that may work for me..can I or how can I detect a specific area on image?for example if it is someone's photo,and I want to detect the coordinates of his eyes..
|
|
|
|
|
Detecting objects in a photograph is a challenge. Do a search for "Computer Vision" or talk to your Computer Science professor at your local university to see how complex a field this is. Unfortunately I can't think of a simple way of doing this.
|
|
|
|
|
Does anyone know any reliable compression library for .net ? Tried to use SharpZlib without success (too much CRC errors)... I tryed managedzlib as well. If anyone know a good library (or a way to call the good and old unmanaged zlib from managed enviroment), please let me know.
|
|
|
|