|
how i store a a voice into text form... please give source code.
|
|
|
|
|
It's all here[^]
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi,
i need to add some items to a listbox in another thread and another class.
The secont thread passes a ListBox item to the invoking function but i cannot access its listbox.items.add functionality. I can only set values to the common parameters to all Controls (i.e. text, name etc.) How could this be solved?
ty
|
|
|
|
|
Create a custom event (and custom EventArgs object). Put the string/item into the EventArgs object and handle the event in the desired location.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
... and avoid cross-thread problems with the techniques from this article[^].
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
I only read code that is properly formatted, adding PRE tags is the easiest way to obtain that. [The QA section does it automatically now, I hope we soon get it on regular forums as well]
|
|
|
|
|
It seems multithreading is being taught in class this week.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Mark Nischalke wrote: It seems multithreading is being badly taught in class this week
FTFY
If Barbie is so popular, why do you have to buy her friends?
Eagles may soar, but weasels don't get sucked into jet engines.
If at first you don't succeed, destroy all evidence that you tried.
|
|
|
|
|
Hi all,
I am refering this[^] article of CodeProject for learning about Windows Services.
Everything went right, but when i tried to Start the service from Services option of Administrative Tools, it is showing me following error:
"The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security."
on this line of code
if (!System.Diagnostics.EventLog.SourceExists("SimpleSource"))
Service is not starting.
Can anybody tell my why this is happening?
Thanks,
Nagendra.
|
|
|
|
|
Maybe it has to do with the user account you installed the service under.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
backgroundWorker1.RunWorkerAsync(mdiForm);
void worker_DoWork(object sender, DoWorkEventArgs e)
{
mLoadForm = new LoadForm
{
StartPosition = FormStartPosition.Manual,
Location = mNewLocation,
TopMost = true
};
mLoadForm.MdiParent = ((MdiForm)e.Argument);
Application.Run(mLoadForm);
}
When I try to set the MdiParent for the loadform by passing the mdiform thru the RunWorkerASync parameter, the Application.Run(mLoadForm) is never reached nor is there an error being thrown ...
This should be possible right?
|
|
|
|
|
You're attempting to do Application.Run within a background worker??!
I don't know what would happen if you do that, but its going to be weird.
Regards,
Rob Philpott.
|
|
|
|
|
If i replace Application.Run(mLoadForm) by mLoadForm.Show() then the Form isn't displayed corretly (I'm running an animated gif in that form)
Bu that doesn't change the fact that I cannot set the MdiParent....
|
|
|
|
|
Also, please explain why this "will be weird", because I didn't notice anything "weird" ...
|
|
|
|
|
Well, Application.Run is traditionally used from the main() entry point to the application. It creates a standard message loop on the current thread which then responds to user input and rendering requests and the like.
It's certainly normal to only have one such message loop, so using two (concurrently) opens up the dubious world of not having a single GUI thread. I've not seen it done before (except in modal dialogs etc.) And although it *may* be possible to use it, its certainly not the correct approach IMO.
You might end up with MTA/STA problems maybe as well.
Regards,
Rob Philpott.
|
|
|
|
|
But that was the purpose: I wanted to create a thread that contains another form while the other was currently busy.So I could show an animated gif in front of the form that is busy...
This seemed to be working great, except that if u minimize or moved the 'busy' form, the form in the new thread with the animated gif stays on screen, so I thought by setting the mdiParent would solve this, but apparently this can't be done...
I will change my design and let the main form do its work async so I can just put a picturebox in front till the work has been done or something ...
|
|
|
|
|
Also thanks for your input
|
|
|
|
|
No problem. I think that's the correct approach to go. You may be familiar with the notion of 'only the thread that creates a window can access it'. This means that you can never create another window on a seperate thread then make that a child of one on another.
If the two windows are completely seperate, you could use two Application.Run()s, although I'd explicity create a thread to do this and call that on it.
Regards,
Rob Philpott.
|
|
|
|
|
Rob Philpott wrote: his means that you can never create another window on a seperate thread then make that a child of one on another.
This makes a lot of sense. Thank you !
|
|
|
|
|
Because you cannot do UI stuff, like creating forms and showing them, on anything other that the app's startup thread, also known as the UI thread.
I do NOT care that "it works for me!". You or, more importantly, your customers WILL eventually find a problem that only shows up under certain circumstances that you're not going to be able to duplicate and, if you do, will be very weird and nearly impossible to track down.
You just do NOT do it if you want your app to be as stable as possible.
You're going about this backwords. You do not keep the long-running work on the UI thread in your main form. You move THAT work to a background thread, freeing up the UI thread to handle putting up a "progress" form and updating it.
UI stuff stays on the UI thread. Actual work stuff goes on background threads.
Using an MdiParent form to do this is just silly.
|
|
|
|
|
Dave Kreskowiak wrote: You're going about this backwords. You do not keep the long-running work on the UI thread in your main form. You move THAT work to a background thread, freeing up the UI thread to handle putting up a "progress" form and updating it.
I already had come to that conclusion if u had read everything.
Dave Kreskowiak wrote: Because you cannot do UI stuff, like creating forms and showing them, on anything other that the app's startup thread, also known as the UI thread.
It IS possible, I had a form popup in front of my main form , created on another thread, with the Application.Run , and I had never ever got an error or something 'weird', because all it did was simply popup, show animated gif and close again.And I have this tested for weeks now...
|
|
|
|
|
ddecoy wrote: It IS possible
Re-read what I posted. I said you may not get any problems, but you will eventually find some issue. Not essentially in this app, but if you continue to use this technique in other situations, you will find problems.
|
|
|
|
|
Hi everyone
My class implementation like
base class : DatabaseWrapper
1) It is abstract one
2) Contains method common to derived class (e.g. select,insert,update,delete)
Derived class :
1) ExcelWrapper
override the common method which are in base class.
2) SqlDatabaseWrapper
- override the common method which are in base class.
- Also has StartTrancation,Rollback and commit method
- also has executestoreprocedure
Now my implementation work fine when
i create object like
SqlDatabaseWrapper sql = new SqlDatabaseWrapper();
sql.StartTranction();
.
...
...
sql.Commit();
but now i have implement like
DatabaseWrapper sql = new SqlDatabaseWrapper();
sql.StartTranction();
.
...
...
sql.Commit();
but i am not able to get the methods.
How we can solved this using Strategy design pattern.
Yogesh Pekhale
pekhaleyogesh@gmail.com
|
|
|
|
|
Sounds to me what you want is an interface, not a design pattern
abstract class DatabaseWrapper
interface ITransactionalDatabaseWrapper
void StartTransaction();
void CommitTransaction();
void RollbackTransaction();
class ExcelWrapper : DatabaseWrapper
class SqlDatabaseWrapper : DatabaseWrapper, ITransactionalDatabaseWrapper
ITransactionalDatabaseWrapper transactionalDb = new SqlDatabaseWrapper();
|
|
|
|
|
Hi J4amieC
Thanks for quick response....
You ans sounds logical, in fact i tried workout well !!!!
but my application requirement is that from base class i need to access the method like
DatabaseWrapper db = new SqlDatabaseWrapper();
i am having another solution of it using Strategy design pattern like
i have
1)ItrnactionalInterface in that startTraction.....
Then i have two concrete class
2)TrancationalDatabase : ItrnactionalInterface // implements transaction
3)Non TrancationalDatabase : ItrnactionalInterface // throwing exception
now in base class i defined it as
abstract class DatabaseWrapper
ItrnactionalInterface tr
// here i had method
void StartTranction
{
tr.StartTranction();
}
and in SqlDatabaseWrapper
tr = new TrancationalDatabase ();
and in ExcelDatabaseWrraper
tr = new NonTrancationalDatabase();
So when i do like :
DatabaseWrapper db = new SqlDatabaseWarpper();
db.StartTransction() // this will call the method from TrancationalDatabase
and if i
DatabaseWrapper db = new ExcelDatabaseWrraper();
db.StartTransction() // this will call the method from NonTrancationalDatabase
This working fine.. according to the strategy design pattern....
but the problem is the object of Transaction which i create in TrancationalDatabase
that i have to use in the SqlDatabaseWarpper.
Now even we can implement as property and access this....
but the problem is come when i am having OracleDatabaseWrapper, MySqlDatabaseWrapper....
Can you suggest any think how i can do this?
Yogesh Pekhale
pekhaleyogesh@gmail.com
|
|
|
|
|
Firstly, and perhaps contentiously I'd forget about the Strategy Pattern. It doesn't event warrent having its own name. (This is just containing a polymorphic base class or interface in another class and providing a method therein to switch the type instantiated). Design patterns usually create more confusion than good.
The trouble you've got is that you don't have a consistent interface on your different derived classes, therefore they cannot be switched in and out. You've got two options, either extend the base class to include the child's additional methods (and provide empty implementations in other children where the method is not applicable) OR somehow call those methods from within those defined in the base class.
If neither of those solutions is applicable, you'll have to treat the two child classes individually with type testing and casts.
Regards,
Rob Philpott.
|
|
|
|