Click here to Skip to main content
14,975,553 members

Comments by Sonhospa (Top 40 by date)

Sonhospa 11-Mar-21 14:20pm View
It's how I named the TabControl. Admittedly, this might be confusing :-)
Sonhospa 11-Mar-21 13:54pm View
Hi again, Ralf,
it seems I was able to RESOLVE it "by accident", too :-) In a systematic approach I deactivated large parts of my code (set as comment) and uncommented parts stepwise. I now have a few lines left that I didn't find suspicious before, but they seem to have caused the problem!

It seems that my tabSelector.SelectedIndexChanged handler confused not only me but also the compiler:

Dim ctrl As TabControl = DirectCast(sender, TabControl)
Dim page As TabPage = ctrl.TabPages(ctrl.SelectedIndex)

If ctrl.SelectedIndex = 0 Then
End If

Despite of the fact that the handler was actually doing nothing ("Stop" was also set as comment before), after deleting all of these statements I have my UI back as before!

Thank you, though, for trying to help – and have a nice evening!
Sonhospa 11-Mar-21 13:19pm View
Thank you for your response, Ralf. No I haven't used the dock property and I guess this would also show at design time. The form designer looks just as it should, and nothing in my code relocates any controls (purposely). The 'many changes' mainly involved read-/write methods etc, nothing I would relate with how the tabs are shown.

In one experiment I tried to select Tab3 at startup (if a condition has been matched), but deleted this piece of code shortly afterwards. Too sad I can't post a screenshot here in order to show what's presented.

BTW I'm using VS2019 Community on a Windows7 (64bit) system.
Sonhospa 4-Sep-20 17:31pm View
Thank you for your help and the idea, and have a nice weekend!
Sonhospa 3-Sep-20 14:42pm View
Sorry that I have to ask you again... I still didn't manage to make it work. The method is called in a click-Handler like this, which should put it on a background thread:
Dim t As Task = Task.Run(Sub()
msg = MethodName(Path, "*.*", System.IO.SearchOption.AllDirectories)
End Sub)

I've set a breakpoint at the "progbar.value = " line and observed that it's not reached for every file but in somewhat arbitrary intervals, which makes the calculation of the value guesswork. I'm sooooo stuck :-( that I'd really be glad about another good idea from you...
Sonhospa 3-Sep-20 11:04am View
That's possible... I'll check and hope to resolve that. Thank you again!
Sonhospa 3-Sep-20 10:39am View
Hi again, sorry but I have a follow-up question... using the code now shows that the progressbar isn't working. First the result shows (for the test I display it in a message box) and AFTER this the progress bar increments. Is it at all possible to show the progress in a parallel.foreach loop?
Sonhospa 3-Sep-20 9:53am View
That's perfect - thank you, Richard!
Sonhospa 21-Jan-20 11:43am View
Thank you, Ralf. As written in my first post, I had the same idea but found it a little bit clumsy ("...von hinten durch die Brust ins Auge" ;-) sozusagen). I hoped someone would have a more elegant solution. Have a nice evening!
Sonhospa 18-Jan-20 5:41am View
Thank you, though!
Sonhospa 17-Jan-20 12:45pm View
Hi Dave, sorry for the delayed response. It may seem weird but is still true - only for some SATA drives. If a user accesses the particular HDD, it takes a few seconds to 'wake up' from some kind of standby-mode I suspect. As mentioned, after waking up I get 'IsReady = TRUE'.
Sonhospa 15-Jan-20 10:43am View
For example by opening an Explorer window (Network list -> server name -> drive letter)
Sonhospa 15-Jan-20 9:20am View
Thank you, Dave. However, it must be something drive-specific as on the same machine e.g. 4 drives are reported TRUE (IsReady) while 2 others aren't - at least not before waking them up manually.
Sonhospa 14-Feb-19 14:45pm View
That seems to be exactly what I'm after, thank's a lot! This means I would instantiate the listBox without the "WithEvents" statement, and add the handler later, right?
Sonhospa 13-Feb-19 13:24pm View
Thank you very much, Richard! After studying different sources for the last weekend, I found exactly this method, tried it and - voilá it works!

Since I'm not a professional programmer, it was also critical for me, where exactly in my code I had to place it. You didn't mention that, but I would have understood implicitly to just change my old line. In addition, following another hint, I inserted "readTask.GetAwaiter()" before "readTask.Start()".

Thank you though, and since it's the 'missing piece' I had initially asked for I accepted your suggestion as solution... if you don't mind ;-)
Sonhospa 9-Feb-19 17:57pm View
Sorry for the hospital thing, I honestly hope nothing severe and all turns out well! Just don't let them give you anything in Latin, that wouldn't be helpful if you didn't study it.

FYI: I'm about following a clue of another forums thread where 'Task.Result' is stored in a variable. Peace!
Sonhospa 9-Feb-19 17:28pm View
Good idea, thank you! Second thought: I just don't understand why it would work properly in VS2015 Express then... Still I'll have a look.
Sonhospa 9-Feb-19 17:05pm View
Maybe I didn't express that clear enough. Of course I started VS2010 (which I usually use) as admin, like you suggested. And the result was similar. The OTHER experiment with VS2015 Express was to find out if my code is involved in the problem or not. And it's obviously not.
Sonhospa 9-Feb-19 16:49pm View
Hi again, yes you did and I looked at them - trying to not get even more confused. Please understand that I'm new to this topic! Here's the MS example I mentioned (sorry I don't find how to insert this in a better way: They don't run into the same problem as they output to the console after every task is finished.
Sonhospa 9-Feb-19 16:22pm View
Hello Maciej, thank you for your time. Following your hint I deliberately did that, but it's exactly the same.

Just to find out if it has to do with my (probably twisted) code, I started the project in VS Express 2015 (not as admin), which runs it without any problem several times subsequently.
Sonhospa 9-Feb-19 16:08pm View
Hey man it's the first time I'm trying this and I already admitted that I didn't understand what you mean. If you don't want to help, just don't answer. Have a nicer rest of the weekend.
Sonhospa 9-Feb-19 15:07pm View
I mean how could I achieve to have my "summary" (counts and duration) on the UI thread, i.e. after the threads are all finished? I deleted Wait already, but "you have to get really creative" I didn't expect as advice and possible solution in this forum. Thank you though.
Sonhospa 9-Feb-19 14:41pm View
Yes, that I understand. I mean how could I achieve to have my "summary" (counts and duration) on the UI thread, i.e. after the threads are all finished? From what I read, the Task.WaitAll is exactly for that purpose... or did I misunderstand that?
Sonhospa 9-Feb-19 14:29pm View
Hello Dave, thank you for having a look. I don't understand what you mean. Having the long running tasks on the UI thread would freeze the UI as well, or not? Sorry, it's a bit complicated for my brain...
Sonhospa 4-Feb-19 11:02am View
Good that you write, now I have a 'Reply' button so that I can thank you as well :-) and apologise for not being used to (and also comfortable with) the changed UI.

Thank you as well for the update / non-Linq version! It's obviously a very cool and brief way to reach the same goal without all the syntax hassle that I unsuccessfully tried to master. And in my learning, the different ways pros go are extremely interesting to me!

Would you think the LINQ version is preferrable for speed or sth else, or is it just a matter of taste?
Sonhospa 4-Feb-19 10:31am View
Thank you again, Maciej. I guess I'll try the way with the extra class 'ShortFileInfo', since with the anonymous type I get an error (can't convert to FileInfo).

By the way your additional explanation helped me a lot!
Sonhospa 4-Feb-19 10:25am View
Thank you though, as from the "pupil's" perspective I understand more from your additional explanations. I also appreciate your very good (!) idea to return a specific type.
Sonhospa 4-Feb-19 10:00am View
This seems to make a lot of sense, as the tasks are running long. THANK YOU for the clue, I'll follow the links you supplied immediately!
Sonhospa 4-Feb-19 9:58am View
Yes, they do. But 90% of other folders, which work well, have spaces in their names as well.
Sonhospa 4-Feb-19 8:37am View
You are wrong. The error is thrown without any change of the LINQ query and surely not related to it's potential extra filtering (which was btw the first thread I opened). Surely two completely different answers, one on general LINQ syntax and one on my implementation of a recursive function.

'How would I apply an extension to my car' has a completely different scope than 'In some areas of the country my car stutters', doesn't it? And for sure different people would answer. It may be the same car though (not necessarily).

Now let's please finish this overly academic waste of time. I don't see how anyone would have fun in reposting, but decided to open two threads after observing that others get criticised for asking different questions on their code in the same thread, thus creating a confused thread in which nobody knows what's resolved now and what isn't.

Sonhospa 4-Feb-19 7:29am View
1. Looking for approach to extend a LINQ query
2. Trying to resolve a DirectoryNotFoundException

Completely different tasks. Have a (more) beautiful day.
Sonhospa 4-Feb-19 7:26am View
1. Looking for approach to extend a LINQ query
2. Trying to resolve a DirectoryNotFoundException

Completely different tasks. Have a (more) beautiful day.
Sonhospa 4-Feb-19 7:21am View
Hi, thank you for taking time.

Maybe you saw in the code that I use Try/Catch with an extra catch of SecurityException and also UnauthorizedAccessException, so I'd guess it's not on that side. I get the error message at the DirectoryNotFoundException, but of course assume that 'GetDirectories' would read a path which 'GetFiles' can use...

I just checked existence of the reported path (or one of them) to make sure, but it is existing but - maybe that's a hint if you're more experienced than I am - it is an EMPTY folder.

EDIT: Another folder reported with the same error is existing as well, but isn't empty. So that clue wasn't right...
Sonhospa 4-Feb-19 7:09am View
Did you read it? It's a completely different question, not a repost.
Sonhospa 4-Feb-19 5:41am View
Thank you, Chill60. I didn't get that right, so your hint relly helps.
Sonhospa 4-Feb-19 5:39am View
Hi Dave, thank you (again) for your answer. Sorry I used the wrong link (not 'reply') to answer so obvously didn't get notified - another member gave that hint to my error.
Sonhospa 1-Feb-19 19:51pm View
Thank you, Dave. I intended to (e.g.) show the currently searched directory in a statusbar. The call to a delegate is commented (green) as when active it resulted in an error (someth. like at breakmark "Code doesn't reach this line and has changed".

I am unsure if it would be wise to give permission to (wichever) changes.
Sonhospa 1-Feb-19 4:25am View
That's much more elegant, Peter - thank you very much!
Sonhospa 31-Jan-19 16:02pm View
Cool, thank you again - I'll give it a read!
And: I've got it to work :-)
Sonhospa 31-Jan-19 14:20pm View
Thank you, Raddevus. I want to understand the delegate/invoke method, that's why I didn't just use the BW. However, I wasn't aware that I'm sending my UI thread to sleep! But there must be more wrong, as the UI isn't updating at all during the loop.