在 Visual Basic 中控制每个循环 [英] controlling for each loop in visual basic

查看:18
本文介绍了在 Visual Basic 中控制每个循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码....

For Each dgvRow In bout_grid.Rows
            vfile = dgvRow.Cells("FileName").Value
            video.FileName = "D:\bee\" + vfile

            vduration = video.Duration
            vposition = video.Position

            If vduration > 0 The
                bplayer_out.URL = "D:\bee\" + vfile
                bplayer_out.Ctlcontrols.play()
            End If

        Next dgvRow

但它只播放一个视频而不是停止,但我希望它应该播放datagridview中的每个视频,即bout_grid ....我已经尝试过

but it plays only one video and than stops but i want that it should play every video in datagridview i.e bout_grid....i have tried

System.Threading.Thread.Sleep = vduration

但它阻止了每一件事我该如何解决它

but it stops every thing how can i solve it

推荐答案

是的,您不能让这种代码在 Windows 窗体或 WPF 应用程序中工作.Windows 应用是事件驱动的,您无法在不阻止 UI 更新的情况下编写长循环.

Yes, you can't make this kind of code work in a Windows Forms or WPF app. Windows apps are event driven, you can't program long loops without blocking UI updates.

Windows Media Player 在发生重大事件时生成事件.就像 PlayStateChange 事件.为该事件编写一个事件处理程序,以索引到列表中的下一项.请注意,WMP 也支持播放列表.

Windows Media Player generates events when something significant happened. Like the PlayStateChange event. Write an event handler for that event to index to the next item in your list. Note that WMP also supports play lists.

在 Visual Basic 中编写 WMP 的最终资源是这个 MSDN 库主题.查看提供的示例.

Your ultimate resource for programming WMP in Visual Basic is this MSDN Library topic. Take a look at the provided samples.

这篇关于在 Visual Basic 中控制每个循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆