The standard way to do this is to use a CancellationToken from a CancellationTokenSource for each one that you want to cancel. You assign this token when you create your task. Your code would look something like this:
As soon as you hit WaitAll, you are telling the system to wait for the tasks to complete somehow. This means you're going to have to cancel the task from inside the running task - which is why I put it inside the running task.
Yes, you can, but you're not buying yourself anything by doing so.
You're still going to have to signal the thread to stop and if your code outside the thread is blocked waiting for the thread(s) to finish its/their task(s), how is your outside code going to cancel that thread?
You won't buy yourself an easier solution by using a thread. You end up with the exact same problem, just using different classes.
Calm down. Like others, I have read your original post and don't really understand what you are asking for. Now, I appreciate that you aren't a native English speaker, so the terms you are using might not be exactly what you think they mean. When you talk about previous open, are you talking about a form that has been closed and that you are loading again? Is it a window that's already open and you have Control-Tabbed to get to it?
I think - but I'm not sure - that he is processing a file and then when his code tries to do something with it again, it locks up. If so, Nathan is probably right that he isn't closing and disposing of streams / handles but without relevant code...
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
What he means is that all of the individual words make sense: it's when you put them together as a question it isn't understandable!
Please, remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you tell us to work with. I can get some bits from it - you have a WinForms app that seems to get stuck when you do something with files, but we don't know what you are doing with them, or how you are doing it in your code. So we ask for clarification - because we are trying to understand your problem in enough detail to help you!
We understand that English may not be your first language, and we are trying to work with you here - but we can't sort out a problem if we don't understand the question!
As a suggestion, try typing the question in your native language with a good level of detail and use Google Translate to convert it - it may make more sense to us that way!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
I wrote a program in C# using VS2010 that has a media page that pulls videos from You Tube. It worked perfectly until this morning. Today, all I get is a blank screen. Even if I get straight to the basics and hard code a movie file into the properties menu, all I get is a blank screen. The only thing that I can see that might have happened is that the program did the newest Windows update (Windows 10) last night automatically. To check this theory, I had a previous version of the application on my laptop that also runs Windows 10 .... so I checked it out and my older version of the same app running on the not updated Windows computer works perfectly. It seems that Windows 10 has destroyed something in the Flash support, maybe the Flash.ocx file? I really don't know. I was supposed to launch this application at the end of this week, so this is a major issue now. I don't know how to repair this. Appreciate any help. Thank You, Pat.
You made a HUGE mistake by relying on Flash. Flash is dying, fast. YouTube's default video player has been HTML5 video for about the last year.
On top of that, what you're doing violates the YouTube terms of service. Using any other play other than that supplied by YouTube is expressly forbidden unless excepted by written authorization by YouTube. Good luck getting that.
Yeah, Flash is updated by Windows Update on Windows 8 and above. It's no longer handled by Adobe and, frankly, Adobe is shutting down support for Flash except for gaming and "premium video", which does not apply to YouTube.
YouTube reserves the right to change their support and how they deliver video at any time and has done so multiple times in the past to prevent you from using your own player. What works today is in no way guaranteed to work tomorrow.
Thank you for your input and response. I am fortunate that someone with your depth of knowledge and credentials took the time to bring me up to date. Since my use is for an application and not a webpage, HTML5 is and never was a solution for me. I understand the legalities and I thank you for bringing it to my attention, but I don't think that there are less than 100 videos posted ON YouTube that explain how to use the Shock-wave Viewer in a C# form to view the content of videos posted on You Tube. Like most things today, and as You Tube already knows (or has found out), as quick as they make a change there will be some one with a new key for the lock. It is not possible to post something in the public domain without having someone else contrive a way to get around it. That said, I prefer to do it right and I will simply have to find (or create) a service and/or system that will let me continue to have videos viewed privately from within proprietary software. Perhaps I will change the videos to (mp4) and host them on my own server. Then I can use the Microsoft Media player that already has libraries in Visual Studio. In my case, the most disturbing thing was the timing. Thank You Again. I would like to be able to call on you for advice and perhaps even do some work for me if you are interested. Best Regards, Pat.
Well, just because "everyone is doing it" in no way at all makes it OK for you to do it.
You're not going to get help with this for 2 reasons.
1) Per the YouTube Terms of Service, what you're doing is a copyright violation. The content belongs to YouTube. The content is not "public domain" and you really don't get to do with it as you please.
2) You're stealing money. By creating your own video viewer you are filtering out the ads that come with the content. That ad money is what pays the bills for the service and also puts money into the pockets of the content producers. By rolling your own viewer, you are taking away that ad money.
Oh, and why would I want to work for someone who thinks so little of other peoples work that you don't want to pay them to do it?
I have a trouble with my code in trying to add a combobox to filter a datagrid. It complains in the dataview constructor ("The best overloaded method match for'System.Data.DataView.DataView(System.Data.DataTable')has some invalid arguments".
It also complains in the declaration of rowgrid object: 'System.Data.DataSet' does not contain a definition for 'DefaultView' and no extension method 'DefaultView' accepting a first argumentof type 'System.Data.DataSet' could be found (are you missing a using directive or an assembly reference?)