|
NeilPrice wrote: it's still running to all intents and purposes just hanging which is what was leading me to wonder if thread contention could be coming into play.
It's a definite possibility. Like Christian said, I'd wrap the LogSomething in a SyncLock to keep multiple threads from writing to the log at the same time. Also, since it sounds like your logging LOTS of information, I'd open the file in the first call to LogSomething and keep it open until the app closes. You can still look at the log file while the app is running, or file is open, in Notepad or some other quick'n'dirty editor that doesn't lock the file itself.
|
|
|
|
|
I wrapped a synclock around there for good measure but it turns out that was unrelated to this hanging issue I was experiencing. I think I had two lines of code outside of any kind of Try-Catch mechanism in the whole thread part of the service - it turns out apparently you have to set a variable before logging what it is
Just about sums up my week really, I can't believe I did that =/ On the bright side I'm a lot more confident in the logging part of the code now anyway
Thanks for your input!
|
|
|
|
|
Hi,
IMO logging should be inexpensive and as real-time as possible, hence buffering, locking, thread switching are to be avoided. I tend to open-append-close for each individual log message, since the last message before the app dies is probably the one you want to catch most of all.
The good news is File.AppendAllText() is a static and thread-safe method that does exactly that:
open-append-close without unnecessary hassle. It does perform security checks over and over, so
you'd better log to a local file without special security issues.
BTW: if you want to add an option to e-mail your log file from within the app, you really need
to copy it first, otherwise mailing it and continuing to log would interfere...
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
My listbox1 and the textbox1 (multilines properties)
When double_click the listbox1, textbox1 = data from list box
Being that the user has to do the event(double_click)several times how do i code the textbox1 to have all the the results of the events?
If the user for example double_click 3,4,5 or 6 times the listbox1, the text box must have 3,4,5 or 6 data from the listbox1 and not only one as I have now
Thanks for your help
-kikica0512-
|
|
|
|
|
Hi,
you can append text like so myTextBox.Text+=newTextToBeAppended;
(chances are you want to append an Environment.NewLine too).
when you always append text, you probably will want to have a "clear" button too.
BTW: if you change the ListBox.SelectionMode you can allow the user to select several consecutive
or non-consecutive items in the listbox (using the shift and control keys where appropriate).
Then the doubleclick handler could combine all selected items (ListBox.SelectedItems) using
a simple foreach loop and string concatenation, saving the user a lot of double-clicks (and foregoing
the need for a clear button).
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
I use this codes but no changes
Private Sub ListBox1_MouseDoubleClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDoubleClick
Dim newTextToBeAppended = Environment.NewLine
**** TextBox7.Text = combobox.Text & "in (select sifrazbroja" & vbCrLf & _
"from zbroji" & vbCrLf & vbCrLf & _
"where" & vbCrLf & _
"cast(case when cijena1 = " & TextBox1.Text & " then '1' else '0' end as int)"
TextBox7.Text += newTextToBeAppended
**** I want this data as many time as I double_click the listbox
|
|
|
|
|
OK,
these are the two most popular mistakes that would lead to the updated text not showing
or not showing right away:
1.
say your form class is called myForm, you have more than one myForm instance; the first one
got created and is visible on the screen, the second or later one(s) is/are created inside
the button click handler, listbox double click handler, or where ever, and that is the one
you are modifying, but since you never Show or ShowDialog it, it does
not show at all, hence you don't see the changes.
If this is the case, the right thing to do is NOT to create more than one myForm instance, and to make sure it is the first and only instance that gets modified. If more than one form class is involved, you need to either pass one form to the other (a bad idea), pass one control to the other form (a bad idea), install a public method to update a form's Control from the outside (acceptable) or a delegate and an event (best practice). There are several articles on this subject here at CP.
2.
you are performing a lengthy operation on the GUI thread, say you modify the textbox text,
then count the number of files on your disk, then exit the lisybox double click handler; as
long as the handler is busy, whatever changes it applied to the GUI Controls will not show;
the GUI will update when the handler exits though.
If this is the case, the right thing to do is NOT to perform lengthy operations on the GUI thread;
for good GUI behavior handler execution should never last longer than say 30 msec. If it
takes more, or could take more, the job must be delegated to a separate thread (a real thread,
one from the ThreadPool, a BackgroundWorker, whatever); be careful then to not let it touch
GUI Controls directly, you would need Control.InvokeRequired/Control.Invoke for that. If you need this, look it up in MSDN and read some CP articles on the subject.
Hope this helps.
PS: next time you show some code, please use the "code block" button below the edit window,
it will insert PRE tags which give a monospaced font, a background color and foremost they
preserve all formatting.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
' in ListBox1_DoubleClick
Me.TextBox1.Text = Me.TextBox1.Text & Me.ListBox1.Text & vbCrLf
Samir R. Ibrahim
modified on Saturday, February 7, 2009 1:38 PM
|
|
|
|
|
|
purva shekdar wrote: i need a code in visual basic 6 tat helps me to search all types of files in all drives of my computer
So, what are you waiting for?? Start writing it! Noone here is going to do your job for you.
Or, did you mean to ask a specific question about a problem you're having with YOUR code??
|
|
|
|
|
purva shekdar wrote: pls help me as soon as possible
Sure.
1 - stop using VB6, it was always crap and has been unsupported for a long time
2 - buy a book on VB.NET
3 - learn to use google and MSDN
4 - now the job is easy.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
|
Noone is just going to hand you a completed project. YOU have to write it yourself. We can help with that part, but as for doing your job for you, forget it.
|
|
|
|
|
Hi Dave
I am new in forum, and I am still learning vb.net
I know vb6 (good) and I am Professional in Foxpro (VFP)
I am an active member on many foxpro forums, and I have my own blog for foxpro
I am telling that to ask a question
in foxite forum, if someone ask this question I can give him
#1 already posted message to his answer.
#2 a link to web page that solve his answer.
#3 a link to my blog that I had already write a document on this question.
Is the rule in here that you don't answer question posted if the person who post
the question did not make some effort?
I am with "make some effort, then post your problem if you get stuck"
Can you point please to #1 #2 #3 which are acceptable and which are not?
Sorry If I ask to much, I Just want to make sure I don't make wrong when posting Q or A
TIA
Samir R. Ibrahim
|
|
|
|
|
Samir Ibrahim wrote: Is the rule in here that you don't answer question posted if the person who post
the question did not make some effort?
Yes. There's just WAY too many "questions" asking for code. There's too much copy'n'paste coding going on in the world and too many "students" who just want their assignments done for them.
So, when someone asks for code, it's chances are VERY high that it's not to help them write their own code.
You can put up any answer you want. I've gotten so tired of "programmers" want their code written for them, they get the standard answer of "if you want code, WRITE IT!"
|
|
|
|
|
|
I think the other point is also that VB6 is no longer supported and you are doing NEW development in it. You originally asked for a solution, not guidance and to top it of you consider it urgent. It is only urgent to YOU.
These points will insure you get no help from the forum which is here to help, not supply code. Seriously, trash the VB6 and move to .net NOW
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
If you insist on using VB6, Google for "FileSystemObject". The logic is "recursive", so you may want to Google that too.
And yes, you asked for the code, not a push in the right direction.
|
|
|
|
|
hi all
i want to import calendar from app such as outlook and hotmail in to my program, which is a template of Diary
does any know how i can go about this or how i can create this in vb.net
|
|
|
|
|
Use the APIs/COM objects
Steve Jowett
-------------------------
Real programmers don't comment their code. If it was hard to write, it should be hard to read.
|
|
|
|
|
i don't want to import it permanetly,it only for, when the user logs in their account in my program and want to view their calendar from hotmail for example,
|
|
|
|
|
I need to populate a combobox with a list of the past 20 years.
So I get
2009
2008
2007
...
I have
For x As Integer = Date.Now.Year - 20 To Date.Now.Year Step -1<br />
form.YearFromComboBox.Items.Add(x.ToString())<br />
Next
but the loop never runs in code. What am I doing wrong please (apart from being in charge of a computer )?
|
|
|
|
|
The first problem with the code, as posted is that your list will be reversed.
i.e. it will give
1989
1990
1991
........
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.”
|
|
|
|
|
Of course. I've been staring at this darn thing for far too long today.
Thanks.
|
|
|
|
|
kanchoette wrote: I've been staring at this darn thing for far too long today
I know that feeling.
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.”
|
|
|
|
|