|
dnqhung wrote: Some one call that is intergrating one software to another software.
It's called Automation in South Asia.
dnqhung wrote: For example, I want to control the text input to TextAloud (using to convert text to human's voice). Anyone know about that?
You'll have a better chance of doing this with programs that are built with automation support in mind from the beginning. In which case, you could use the interfaces for automation exposed by the program.
In other cases, you could write code that generates events like mouse click, key presses, read the values of controls, etc., by writing code. This technique may or may not work, depending on the type of the UI you're dealing with.
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
Long time ago,i read one similar project in this forum. He intergrated one chat software (may be Window live messenger, i don't remember exactly) in to his application. However in this case, he used COM interface. In my case, how can i write the interface if the software don't support COM interface. Can you explain more about "automation". In my problem, i want to control a software run "underground" (still running when you close it's main window, such as IDM), so how can i write code that generates events like mouse click, key presses, read the values of controls, etc.
dnqhung
|
|
|
|
|
|
it's not command-line utility. i want to control one text to speed software.
thanks.
dnqhung
|
|
|
|
|
I have started to make a tile map editor, its going to be my first project of a reasonable size and I have made a start
It is in .Net 4 and uses windows forms + CodeContracts.
Currently I have worked on a tool bar and its "Create a map" behaviour.
It would be really helpful if people could have a look of my progress so far, and give me some feedback.
I am not too sure how good my code/architecture is and it would help me allot!
I have uploaded the project code as a .zip and it should be easy to launch: http://www.mediafire.com/?oaa56nhu2as7zy0[^]
Thanks
|
|
|
|
|
Sorry, but...
Would you download and open anonymous zip files from people you do not know?
Nope. Nor would I.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Digital man: "You are, in short, an idiot with the IQ of an ant and the intellectual capacity of a hose pipe."
|
|
|
|
|
How to destroy object (observer) if it is referenced in another class and in destruction code of the observer it asks the subject to detatch it?
In C++ it is possible to call delete to invoke destructor but in C# assigning null to observer object will not release it as there is active reference in the subject.
Once the observer attached to its subject it is not possible to stop observation following strictly destructor patterns as in C++.
What is the best way to destroy observer object?
Чесноков
|
|
|
|
|
Chesnokov Yuriy wrote: How to destroy object (observer) if it is referenced in another class
in C# there is no notion of destructor. Leave it to GC (Garbage collector). If your class implements IDisposable you can call Dispose() , but that is not equivalnt of destructor. Look here[^] for more help
|
|
|
|
|
C# does have Destructors[^].
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
Who knew. I stand corrected.
|
|
|
|
|
Isn't that just syntax sugar for a Finalize implementation?
|
|
|
|
|
Finalizers basically are destructors. They get called when the instance is destroyed. The main difference between, say, C++ and C# is that the destruction may occur at a different time.
|
|
|
|
|
I'm not 100% sure this will apply in your case, because of the involvement of more than one class, but I have used the following technique in the past.
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
foreach (NameOfEventHandler eventDelegate in NameOfEvent.GetInvocationList())
{
NameOfEvent -= eventDelegate;
}
components.Dispose();
}
base.Dispose(disposing);
}
I hope that you can make sense of that.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
I wouldn't let CG touch my Abacus!
When you're wrestling a gorilla, you don't stop when you're tired, you stop when the gorilla is.
|
|
|
|
|
Without seeing some code, I can't be too sure of exactly what you are talking about. However, after reading this sentence:
Chesnokov Yuriy wrote: in C# assigning null to observer object will not release it as there is active reference in the subject
...I am thinking maybe you need a WeakReference. Essentially, a WeakReference allows an instance of a class to be referenced, but the garbage collector will not treat that instance as being referenced if it is only referenced by a WeakReference. That does not guarantee the object will be disposed of immediatly, but it does allow it to be an immediate candidate for garbage collection. Here is a small example:
WeakReference reference = new WeakReference(new MyClass());
|
|
|
|
|
|
Using 2010.
What I would like to do is split up the work that a function is performing to two seperate backgroundWorkers. Is it possible to have each worker run off the same function or do I need to create a second function that is a copy of the first? Quick stright forward example:
Lets say I want to count to 100,000,000 and write each increment to a CSV file.
So "worker1" calls CountToWhatEver and start = 1 and end would equal 50,000,000 and "worker2" calls CountToWhatEver where start = 50,000,001 and end equals 100,000,000. Order in the csv file doesn't matter so long as it's there.
So if it were to read: 1,50000001,2,3,500000002,4,5,50000003 that would be fine.
Thanks in advance!
|
|
|
|
|
The same function can be used for both.
Just make sure the variables are defined inside the function, not at the class level, so each thread will have its own set. Otherwise you could have two different threads trying to count using the same integer variable.
|
|
|
|
|
I would need to obviously pass the variables to each thread, that would work the same way as normal right the name of the function and then (intStart, int End) for example? Thank you, that will make my life so much easier.
|
|
|
|
|
Generally, you provide arguments to a background worker via the DoWorkEventArgs parameter. When you give an argument to RunWorkerAsync(arg) , it can be accessed within the function as e.Argument ... So you could create a small structure or class that contains fields for the start and end indices, and pass that as the single argument.
|
|
|
|
|
You can share code across threads as much as you like; and you can share read-only data. As soon as shared data starts to change though, you need to take precautions. Having both threads write to a single file is a recipe for trouble. Witgout precautions you might get any of the following:
1,2,3,4,5,50000001,50000002,50000003,50000004,50000005,6...
1,50000001,2,3,500000002,4,5,50000003...
1,5002,3,00001,500000002,4,5,50000003...
the third line should worry you.
Anyway, threads help when the problem is too much calculations (non-blocking CPU activity) or too much uncertainty in the exact sequence of operations (blocking CPU activity as in I/O), they don't help much (or at all) when the problem is memory bandwidth or peripheral bandwidth. Having two threads doing nothing but writing a file does not make sense to me, it will either go wrong or be slower than a single thread doing the same; having multiple threads doing many things including writing to a single file needs a different approach, probably one where data gets collected, not written, by several threads, then filed by a single thread.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
Good point and you picked up on the question I had thought of during lunch (obviously still new to multi threading). So what I'm thinking is perhaps two seperate files and then adding the one to the other once they are both done. Which brings me to my next question in this... how am I going to tell when both of these are done... would it be a 3rd function that acts like a master checking on the workers every so many seconds with a worker1 are you done, worker2 are you done? Once completed go do this with the results?
Thanks for the answers thus far they have been really helpful, wish books covered this kind of thing, most just give you some useless example and forget to mention multiple workers or working with classes...
|
|
|
|
|
One of my older articles[^] may give you something to ponder (or give you indigestion ), but I don't think it will help much for the process you describe.
Is this task something you really need to do? Or are you just trying to learn about using threads?
|
|
|
|
|
you could have a common RunWorkerCompleted handler and organize a counter of outstanding BGW's, which you would increment before launching a BGW, and decrement in the Completed handler (that would all be on the same thread), so a volatile numeric value type would behave as you'd expect. Alternatively you could use the Interlocked class and use its Increment and Decrement methods.
However you don't have to gather both halves of the output and then combine them though; it suffices to gather a reasonable amount (say 100KB) of output (in each thread separately) and then output it, while holding a unique lock to avoid problems without paying too much overhead.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
If you are looking to speed up file system access, the short answer is that you're not going to be able to. If you write to 2 files, you're just going to slow the process down, because now the hard drive will have to seek between each file rather than stream to a single file. If they were on different hard drives, that might work, but then there'd be no way to combine them into a single file in a quick manner (well, maybe a virtual file system of some sort could help with that, but that's probably not something you're going to be considering).
|
|
|
|
|
Luc Pattyn wrote: Having two threads doing nothing but writing a file does not make sense to me
My thoughts exactly.
The actual I/O to the disk is the primary bottleneck in the process described, so I suspect doubt that even having each thread writing its own file would help.
modified on Thursday, February 10, 2011 12:57 PM
|
|
|
|
|