Hi
I want to define videos in below string say and then loop all the videos one by one.
var videos = new List
{
};
await Task.Run(async () =>
{
}
Hi
I want to define videos in below string say and then loop all the videos one by one.
var videos = new List
{
};
await Task.Run(async () =>
{
}
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ramco RamcoPosted Apr 29, 2024, 9:53 AM
Hi Naimish
I have below code. What is happening . It opens 1,2,3, video but only last one is run. I want first video should run then second,third and so on.
Thanks
Jaydeep PatilPosted Apr 28, 2024, 7:41 AM
Hi Ramco,
You can refer to the to the below code for looping.
Jignesh KumarPosted Apr 27, 2024, 6:14 AM
Hello Ramco,
You can use below one,
here, I have used Parallel to iterate over the videos collection in parallel
.ForEachInside the
Parallel.ForEachdelegate, weawaitan asynchronous methodProcessVideoAsyncfor each video URL.The
ProcessVideoAsyncmethod simulates an asynchronous operation for processing each video. You can replaceTask.Delay(1000)with your actual asynchronous operation, such as downloading or playing the video.Naimish MakwanaPosted Apr 26, 2024, 11:56 AM
Sure, I can help with that. Here’s an example of how you might define a list of video URLs and then loop through them one by one in C#:
In this example,
videosis a list of strings where each string is a video file name or URL. TheTask.Runmethod is used to start a new task that runs the provided action. Inside this action, we loop through each video in thevideoslist, print out a message saying which video is now playing, and then wait for a certain amount of time to simulate the video playing. You should replace theConsole.WriteLineandTask.Delaylines with your own code to actually play the videos.Thanks
Jayraj ChhayaPosted Apr 26, 2024, 10:25 AM
To define videos in a string list and loop through them in C#,