|
CiNN wrote: I am using AllocConsole to add a console window to a window form at runtime
Why?
|
|
|
|
|
|
hi all
i save a file in my program in an extension that i made
so i wanna this file to have the icon of my program how can i make it
thanx
Generator
|
|
|
|
|
You can do it manually in many ways:
- through Windows Explorer, Tools, Folder Options, File Types;
- more easily: by double-clicking a file with the new extension; Windows will guide
you through the process.
And you can do it programmatically, it has been described in many CP articles;
search for "File Association".
|
|
|
|
|
|
Hello,
I hope one of you have found a solution to the following problem before. . . Thanks in advance if you have.
I have to implement an interface defined in an external program - I must have a method Notify() in my object
toimplement that interface. When there's an update, the Notify() method is called by the external program. I can
then collect any updates with a method call that returns a System.Array consisting of an ID (given by me when
implementing the connection), and a value.
The problem is that the array that I collect updates from is of fixed size (subsequent updates are not added to
the end of the array like a queue. . ), so sometimes by the time I've collected the update, set a member variable
in another object to the value (m_Object.SomeValue) and returned to respond to any subsequent Notify() calls, the
updates have been overwritten and I've missed some updates. . . Not great. I've removed any calculations I was
doing in these Set() methods, but it still doesn't return in time. .
This is a sample of my set-up:
ManualResetEvent m_NotifyEvent;
Thread m_UpdateThread;
. . . .
m_NotifyEVent = new ManualResetEvent(false);
m_UpdateTHread = new THread(new ThreadStart(RTDUpdates));
m_UpdateThread.Start();
... . .. .
private void RTDUpdates()
{
m_NotifyEVent.WaitONe();
System.Array arrValues = m_RTDServer.RefreshData();
if(arrValues > 0)
{
for (int i =0; i
|
|
|
|
|
You could always store it in a List<...> or ArrayList internally and then just copy it out to an array to return it out.
|
|
|
|
|
tobriain wrote: How can I concentrate on maintaining the proper state of the variables
You mean like making a copy of the Array as your first step?
|
|
|
|
|
Thanks for the swift replies. .
>You mean like making a copy of the Array as your first step?
In any case, processing the updated array, setting the values and returning in time doesn't seem to be working. If I make a copy of the array and return immediately, i'll end up having maybe 10 arrays per second. I need to get the values out of the update array on one thread, maybe, and put them into some kind of dynamic list. Then on another thread, I need to take the values out in order, and set the variables. If that works, although the variables will be set a little bit later than before, they will be set in order, with none of the updates being dropped. How do I go about doing that?
Best regards,
Tom.
|
|
|
|
|
tobriain wrote: How do I go about doing that?
I don't know what you are asking? You have still not supplied a complete description of your Problem/Goal. Surely putting values into member variables is not the end goal of your processing.
|
|
|
|
|
Thanks again for the help.
It's not the end goal, no. I set variables, do some processing and comparisons based on the updates, fir events, update a GUI, save a log etc. Everything after that is working perfectly. Once the variables are set with the updates, my application works as expected. The only problem is that I'm dropping updates. I'm collecting a value from an 'intray' in an external program - an intray that only has space to store one update. I need a thread that does nothing but collect updates, throw them onto a queue and return immediately.
Then I need to nofify a method that updates are on the queue, and get it to remove the updates in order, set variables accordingly and clear the queue. The problem is that I need to do that without 'locking the queue', because then my other thread will not return to collecting data from the external program in time. . . . Any ideas?
Best regards,
Tom.
|
|
|
|
|
Sounds to me like you have a good handle on what you need to do, but are not certain about the details.
What I perceive that you need is this:
1. You need to declare a class available AutoResetEvent.
2. You need to declare a dynamic list of some sort. In this case Queue would work perfectly.
3. You need to set up a thread that runs when this thread becomes signaled.
4. In your notify event handler do two things,
A. Put the incoming data block/message onto the queue.
B. Signal the autoresetevent that there is data to process.
In your data processing thread, make sure that it runs until all items on the queue are processed before returning to wait for the next signal.
As for locking, use a synchronized queue. That way the locking is done for you. If you're worried that locking the queue will cause the notification method to take too long, then you are not using locks properly. You should only lock the queue when you are adding to it or removing from it. Otherwise there should be no need to lock.
Uhm, yeah I spent 6 years dealing with a very similar situation.
Hopefully this helps.
Phil
|
|
|
|
|
Fantastic. Nose to the grindstone now. .
|
|
|
|
|
Phil, I've just one question about your suggestion, and would appreciate you help as you've obviously spent time putting together something robust along the same lines.
At the moment, if I create multiple RTDServers, all the different calls to UpdateNotify() will be on the same thread. Is that correct? Should I thread them out, so that the initial calls can be made on separate threads?
Could I just create a delegate with the same signature as my RTDUpdates method and make a call to BeginInvoke in the UpdateNotify method to queue all the updates on the ThreadPool? (It doesn't matter if the updates are not processed in order). If I do something like that, do I need a dummy EndInvoke to close the AsyncWaitHandle?
When UpdateNotify is called, could I make a call to to a new method (one that calls the RefreshData method) with BeginInvoke, and then set up the RTDUpdates method as the callback method?
I'd appreciate any pointers you could give me on this, as I'm sure some of the above are illadvised for various reasons.
Best regards,
Tom.
|
|
|
|
|
I'm not certain I understand the design of your software system. Please give more specific details such as: Are there one or more executables creating the data that is to be displayed? Are there one or more executables reading and displaying this data? Is there any other processing besides getting the data ready for display?
When updating the UI from a separate thread, one should always use the delegate and begin invoke calls in the UI method for the reason that the UI processing will be done on the UI thread. You don't need to worry about calling the end invoke method, that method is called by the UI thread when it is finished and the clean up will ensue.
As for how to setup the delegates for the UI properly, you can read up on that in your help documentation. Look up the key word "delegates".
Phil
|
|
|
|
|
led mike wrote: I don't know what you are asking? You have still not supplied a complete description of your Problem/Goal. Surely putting values into member variables is not the end goal of your processing.
Thanks again for the help.
It's not the end goal, no. I set variables, do some processing and comparisons based on the updates, fir events, update a GUI, save a log etc. Everything after that is working perfectly. Once the variables are set with the updates, my application works as expected. The only problem is that I'm dropping updates. I'm collecting a value from an 'intray' in an external program - an intray that only has space to store one update. I need a thread that does nothing but collect updates, throw them onto a queue and return immediately.
Then I need to nofify a method that updates are on the queue, and get it to remove the updates in order, set variables accordingly and clear the queue. The problem is that I need to do that without 'locking the queue', because then my other thread will not return to collecting data from the external program in time. . . . Any ideas?
Best regards,
Tom.
|
|
|
|
|
tobriain wrote: Any ideas?
Might be a good time to condsider a Message Queue.
|
|
|
|
|
What does it mean? When are you supposed to use this?
|
|
|
|
|
it is part of an identifier, just like regular letters and digits.
Some people prefix an underscore (or even m_) to indicate a class member,
as opposed to a method's parameters. And lots of people dont like it.
|
|
|
|
|
Luc Pattyn wrote: And lots of people dont like it.
And I don't like this kind of people!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Is there anything in the Dot Net framework 2 that would allow me to use a Queue Collection but where the data is read from and written to disk rather than kept in memory.
I want to be able to add a large amount of items to the queue (100,000+) and for the data in the queue to be stored on disk so that the data can be kept whwn when the application is off. I suppose it would be like a very small database.
Any idead would be greatly appreciated.
Many thanks,
Bara
|
|
|
|
|
Hi
Not sure I have enough information from you as this seems like quite a simple solution.
Can you not just use a streamwriter to write to a text file then regenerate the queue according to the order the info was written to the file
Hope this helps
Dan.
|
|
|
|
|
The simple answer is "No". At the very least an object that does this sort of thing may be available, but I have not heard of it yet.
However, if you look back to the old days of dBase and other simple data base programs, you could use the ideas from that era. Those ideas are that the records are stored to the HD and the location in the file is kept in another "index" file. This index file could be kept in memory easily and would provide a quick reference as to where the data is stored in the file.
As always, there are alternatives to this which others may well enlighten you about.
Phil
|
|
|
|
|
I am opening a word doc (in C#) and doing a find and replace after which i am using the .printout (below) - which is printing to a local pdf port. However, i get a popup to asking to click Save or Cancel. How do I bypass that?
object Background = true;
object Append = false;
object Range = Word.WdPrintOutRange.wdPrintCurrentPage;
object Items = Word.WdPrintOutItem.wdPrintDocumentContent;
object Copies = "1";
object Pages = "1";
object PageType = Word.WdPrintOutPages.wdPrintAllPages;
object PrintToFile = false;
object Collate = true;
object ManualDuplexPrint = false;
object NullObj = System.Reflection.Missing.Value;
oApp.Visible = true;
oApp.ActivePrinter = "Adobe PDF";
oDoc.ActiveWindow.PrintOut(ref Background, ref Append, ref Range, ref OutputFileName, ref NullObj, ref NullObj, ref Items, ref Copies, ref Pages, ref PageType, ref PrintToFile, ref Collate, ref NullObj, ref ManualDuplexPrint, ref NullObj, ref NullObj, ref NullObj, ref NullObj);
|
|
|
|
|
Doesnt Word do the same thing (show the save/cancel dialog) when you manually open
and print a document ? if that is still true, I dont expect there is a way around that.
|
|
|
|