|
Thanks, Luc. I've been reading a lot now and walking through C# examples with my little VB knowledge (BTW I just loved the Asynchronous Method Invocation[^] one).
Still the most important thing in my particular situation is unclear to me: From my main thread (ID10) I start a BackgroundWorker (e.g. it gets ID6) and within this thread I tried to start another BGW which is supposed to open a form (frmDump). From my efforts to trace the IDs I assume it uses the same thread ID (ID6) instead of getting a new one? If so, then this might very well be the reason for the freezing form, right? The first BGW finishes thread ID6, killing the forms instance which I intended to start in a new thread...
Would you be so kind as to give me some example code lines?
Thanks,
Mick
|
|
|
|
|
Hi,
as I said before, all GUI stuff must occur on the main thread, hence NOT on a BackgroundWorker. It just will not work reliably, or not at all, or only for some time. It is WRONG.
Don't bother with thread ID's, you cannot get it right unless you do all GUI stuff on the main thread, no matter what they tell you, it is bound for failure.
FWIW: BackgroundWorkers run on ThreadPool threads, as I have documented here[^].
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Thanks again, Luc - but you made it clear already. I might be expressing misunderstandingly, so I have to ask you again, hoping you're in a buddhist kind of mood
The message WHAT I would have to do has become a bit clearer after the articles, but HOW would I do it?
Trying it in other (and hopefully better) words here's my challenge again: I have a certain condition (tested in the first BGW within a 'process filearray' method) which should effect (run by who ever as long it's not me ) in a new form, using the relevant fileinfo object from the BGWs method. This new form has to be independent from the main form (i.e. not blocking it while doing it's own stuff), that's why I tried a separate thread / BGW.
Somehow it doesn't seem very elegant returning a fileinfo object back with 'reportprogress' and then start another thread using that same fileinfo as its parameter... or is that the way to make it work? Do I even need a separate thread for the new (independent) form?
Regards
Mick
|
|
|
|
|
Hi,
Forms don't need threads, they can't make good use of threads, since anything that happens to a Form (i.e. calling properties and methods of Controls) has to be executed by the main thread.
Classes in general may make good use of threads for things that take long or might take long, such as complex computations, networking, large file operations, database accesses, etc.
So you should design your class/classes as if they were running on the main thread; then isolate the long running stuff and delegate that to another thread or BackgroundWorker, which could feed back intermediate results to the main thread for showing them on a GUI. There is an infinite number of ways to do that. If a lot of results need to be fed back, you could design a small "Results" class, have your BGW create and fill an instance, then put it in some queue, and have the main thread get it and process it, i.e. display it. You may or may not use the Progress event for that, I typically don't use it; instead, I often tend to create a delegate and call that.
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
|
|
|
|
|
Ahaaaa - that's basic information I needed for some ideas how to unblock the main thread of my brains again I'll redesign asap and consider the way you recommended to do it!
Thanks and regards,
Mick
|
|
|
|
|
hi,
i did simple db connect with server and client across LAN.
actually i pass connection string from global file.
how to give server location for client side during run time.
or give some other suggestion.
plz
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
Mail To : foreverkans@gmail.com
|
|
|
|
|
We used to connect to the MS Access file through the network.
What you need is the shared folder over a LAN where DB file is placed
Now to access the file give path as
\\<IP Address>\<Folder Name>\<File Name>
|
|
|
|
|
well, i have a similar issue that i am working on. maybe this will work on Win XP OS's..
but i tried it on my Win Vista and 7, i get an error that says. cannot open DB, restrictions are blah blah blah..you do not have enough permission. but the folder/file is shared with full read/write control.
even in my Xp workstation, sometimes i get the same error. maybe because there are a lot of computer trying access the db simultaneously?
any ideas on Win Vista and 7?
|
|
|
|
|
All you do is change the connection string to reflect the name of the new server. It's nothing more than simple string manipulation. You can create your connection string with a well-known tag in place of the server name, then just search for and replace the tag in the string with the name of the server. The result is your updated connection string.
|
|
|
|
|
Hello,
i am trying to export data from a vb.net application to an excel spreadsheet. It works but somehow some of the variables are right aligned in their field.
Is there any way to algin a whole column to the left.
I am using Microsoft.Office.Interop
|
|
|
|
|
Worksheet.Columns.HorizontalAlignment property should do that.
Or
((Range)WorkSheet.ColumnsObj[Type.Missing, "A"]).HorizontalAlignment
Not tested though.
|
|
|
|
|
Thanks!
Worksheet.Columns.HorizontalAlignment = = Microsoft.Office.Interop.Excel.XlHAlign.xlHAlignLeft
Worked perfect.
|
|
|
|
|
I have an exe application which is on vb6. I want to remotely push it into different machines and run it as a service there.This service should start as soon as the user logs into his machine.
Please tell me if it can be achieved and how to do it? Thanks.
|
|
|
|
|
As VB6 was always a useless language, and has not been supported for 7 years now, you should put VB6 in your subject, to attract the help of the 3-4 people still using it.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
IMO VB6 was only a useless language for people who can not program. In addition, Microsoft's support for VB6 did not end until March or April of 2008, which is significantly less than 7 years ago. And, FWIW, the name of this message board is 'Visual Basic', not 'VB.NET', so there is no real requirement that individuals specify what flavor of VB they are working with when posting their questions. You don't complain when people who are working with .NET do not specify that in the subject of their questions, so maybe you should consider showing the same respect for those who still work with VB6.
|
|
|
|
|
Member comments reflect the fact that VB6 is not what current day development "should be" done with. If you asked any Microsoft developer what they use in-house, its highly improbable that anyone would state VB6. Sure, some companies and people may not have the resources to convert everything to .Net still and you may be forced to remain on VB6, but the vast majority of developers here use .Net.
paas wrote: so there is no real requirement that individuals specify what flavor of VB they are working with when posting their questions.
The vast majority of members here use .Net and it is assumed if not specified, that's what the orig. poster is using. If not and the poster did not state it as such, you will not get correct answers to your question(s) and yes, probably "encouraged" to move up to .Net as well.
Sorry, such is the way of life with evolution. Adapt to your surroundings or become extinct.
"There's no such thing as a stupid question, only stupid people." - Mr. Garrison
|
|
|
|
|
paas wrote: IMO VB6 was only a useless language for people who can not program.
True. Programmers could use C++ to make COM objects that took up the slack of what VB6 could not do. VB6 itself was DESIGNED for people who cannot program.
paas wrote: And, FWIW, the name of this message board is 'Visual Basic', not 'VB.NET'
Yes, but 99% of the questions are VB.NET. I didn't say 'wrong forum', I said 'you need to tell people on the subject that it's VB6 because people will assume VB.NET until told otherwise'.
paas wrote: In addition, Microsoft's support for VB6 did not end until March or April of 2008, which is significantly less than 7 years ago.
Really ? Well, I know they were eager to bury it right away, I guess enough people complained to drag out it's death.
paas wrote: You don't complain when people who are working with .NET do not specify that in the subject of their questions
No, because VB.NET is a modern, supported language that was designed rather than thrown together. It's what most people use, it's implicit when you say VB today, just like if you said you speak Greek, you'd assume modern, not ancient Greek.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Properly written, you don't. If you want to run an .eXE when a user logs in, this is not done as a service, but as a normal executable running out of the Registry's Run key.
|
|
|
|
|
use the sc.exe in the system32 folder. This will allow you to create, name, and assign an exe to a service. This can be easily done in a small batch script shelled out by the vb or in vbscript. A seperate script is not bad, but this does require to either sleep the thread, run another thread during execution of the script
|
|
|
|
|
I want select my form name from combo box and then
list my selected form controlsname in list box
but selecteditem in combobox is a string and control property for string is not valied
please help me
|
|
|
|
|
I can think of two ways. Either use System.Activator.CreateInstanceFrom or have the value member of the combo as the instance of the form.
|
|
|
|
|
please send me a example for this session
|
|
|
|
|
I assume this means you tried using what I told you yesterday, but don't really know much of anything about C# or winforms. Your forms have a Text property which is the title of the window. You can also use GetType().ToString() to get the name of the class. Either way, you really need to read a basic winforms book, so you can understand the answers you're given
you should also consider reading the posting guide - help me is obviously useless as a title, everyone posting here wants help.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian Graus wrote: You can also use GetType().ToString() to get the name of the class.
Could not get this. How can you get the instance of form by the a string variable having its text (I guess this is what he asked) using GetType(). Can you show some example?
|
|
|
|
|
d@nish wrote: How can you get the instance of form by the a string variable having its text (I guess this is what he asked) using GetType().
You don't, that's not what he asked. He asked how to get the open forms, and I said Application.Current.OpenForms ( or something like that ). He's then tried to assign THAT to his combo, instead of getting the strings he wants from there.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|