示例:WPF中Slider控件封装的缓冲播放进度条控件
原文:示例:WPF中Slider控件封装的缓冲播放进度条控件
一、目的:模仿播放器播放进度条,支持缓冲任务功能
二、进度:
实现类似播放器中带缓存的播放样式(播放区域、缓冲区域、全部区域等样式)
实现设置播放中断时满足缓存够一定数量才继续播放的功能
实现设置缓存数量最大限制,即缓存够一定数量即停止缓存,减少开销
实现缓存中缓存进度的获取
二、示例(GIF)
三、实现:
1、UI部分
添加用户控件:BufferPlayControl.Xaml
设置Slider样式
-
<!--Slider模板-->
-
<Style x:Key="Slider_RepeatButton" TargetType="RepeatButton">
-
<Setter Property="Focusable" Value="false" />
-
<Setter Property="Template">
-
<Setter.Value>
-
<ControlTemplate TargetType="RepeatButton">
-
<Border Background="{TemplateBinding Foreground}" CornerRadius="5" />
-
</ControlTemplate>
-
</Setter.Value>
-
</Setter>
-
</Style>
-
-
<Style x:Key="Slider_RepeatButton1" TargetType="RepeatButton">
-
<Setter Property="Focusable" Value="false" />
-
<Setter Property="Template">
-
<Setter.Value>
-
<ControlTemplate TargetType="RepeatButton">
-
<Border Background="{TemplateBinding Background}" CornerRadius="5" />
-
</ControlTemplate>
-
</Setter.Value>
-
</Setter>
-
-
</Style>
-
-
<Style x:Key="Slider_Thumb" TargetType="Thumb">
-
<Setter Property="Focusable" Value="false" />
-
<Setter Property="Template">
-
<Setter.Value>
-
<ControlTemplate TargetType="Thumb">
-
<Grid>
-
<Grid.ColumnDefinitions>
-
<ColumnDefinition/>
-
<ColumnDefinition/>
-
</Grid.ColumnDefinitions>
-
-
<Border Background="{DynamicResource S_AccentBrush}"/>
-
-
<Border Grid.ColumnSpan="2"
-
CornerRadius="4"
-
Background="{TemplateBinding Foreground}"
-
Width="8" Height="8" Margin="-8"/>
-
</Grid>
-
</ControlTemplate>
-
</Setter.Value>
-
</Setter>
-
</Style>
-
-
<Style x:Key="Slider_CustomStyle" TargetType="Slider">
-
<Setter Property="Focusable" Value="false" />
-
<Setter Property="Template">
-
<Setter.Value>
-
<ControlTemplate TargetType="Slider">
-
<Grid>
-
<!--<Grid.Effect>
-
<DropShadowEffect BlurRadius="20" ShadowDepth="1" />
-
</Grid.Effect>-->
-
-
<Border Grid.Column="1" BorderBrush="Transparent" BorderThickness="1" CornerRadius="8,0,0,8">
-
-
<Track Grid.Column="1" Name="PART_Track">
-
<Track.DecreaseRepeatButton>
-
<RepeatButton Style="{StaticResource Slider_RepeatButton}"
-
Foreground="{TemplateBinding Foreground}"
-
Background="{TemplateBinding Background}"
-
Command="Slider.DecreaseLarge"/>
-
</Track.DecreaseRepeatButton>
-
-
<Track.IncreaseRepeatButton>
-
<RepeatButton Style="{StaticResource Slider_RepeatButton1}"
-
Foreground="{TemplateBinding Foreground}"
-
Background="{TemplateBinding Background}"
-
Command="Slider.IncreaseLarge"/>
-
</Track.IncreaseRepeatButton>
-
-
<Track.Thumb>
-
<Thumb Style="{StaticResource Slider_Thumb}" VerticalAlignment="Center"
-
Foreground="{TemplateBinding Foreground}"
-
Background="{TemplateBinding Background}"/>
-
</Track.Thumb>
-
</Track>
-
</Border>
-
</Grid>
-
</ControlTemplate>
-
-
</Setter.Value>
-
-
</Setter>
-
-
</Style>
-
-
<Style x:Key="Slider_CustomStyle1" TargetType="Slider">
-
<Setter Property="Focusable" Value="false" />
-
<Setter Property="Template">
-
<Setter.Value>
-
<ControlTemplate TargetType="Slider">
-
<Grid>
-
<!--<Grid.Effect>
-
<DropShadowEffect BlurRadius="20" ShadowDepth="1" />
-
</Grid.Effect>-->
-
-
<Border Grid.Column="1" BorderBrush="Transparent" BorderThickness="1" CornerRadius="8,0,0,8">
-
-
<Track Grid.Column="1" Name="PART_Track">
-
<Track.DecreaseRepeatButton>
-
<RepeatButton Style="{StaticResource Slider_RepeatButton}"
-
Foreground="{TemplateBinding Foreground}"
-
Background="{TemplateBinding Background}"
-
Command="Slider.DecreaseLarge"/>
-
</Track.DecreaseRepeatButton>
-
-
<Track.IncreaseRepeatButton>
-
<RepeatButton Style="{StaticResource Slider_RepeatButton1}"
-
Foreground="{TemplateBinding Foreground}"
-
Background="{TemplateBinding Background}"
-
Command="Slider.IncreaseLarge"/>
-
</Track.IncreaseRepeatButton>
-
-
<!--<Track.Thumb>
-
<Thumb Style="{StaticResource Slider_Thumb}"
-
Foreground="{TemplateBinding Foreground}"
-
Background="{TemplateBinding Background}"/>
-
</Track.Thumb>-->
-
</Track>
-
</Border>
-
</Grid>
-
</ControlTemplate>
-
-
</Setter.Value>
-
-
</Setter>
-
-
</Style>
用两个Slider叠加,一个用来播放进度,一个用来缓冲进度
-
<Grid>
-
-
<Slider Height="5" Value="{Binding ElementName=control,Path=BufferValue,Mode=TwoWay}"
-
Maximum="{Binding ElementName=control,Path=MaxValue}"
-
Minimum="{Binding ElementName=control,Path=MinValue}"
-
SmallChange="{Binding ElementName=control,Path=SmallChange}"
-
Background="{DynamicResource S_GrayNotice}"
-
Foreground="Gray"
-
Style="{StaticResource Slider_CustomStyle1}" VerticalAlignment="Center"
-
IsHitTestVisible="False"/>
-
-
<Slider Height="5" Value="{Binding ElementName=control,Path=Value,Mode=TwoWay}"
-
Maximum="{Binding ElementName=control,Path=MaxValue}"
-
Minimum="{Binding ElementName=control,Path=MinValue}"
-
SmallChange="{Binding ElementName=control,Path=SmallChange}"
-
Background="Transparent"
-
Foreground="{DynamicResource S_AccentBrush}"
-
Style="{StaticResource Slider_CustomStyle}" VerticalAlignment="Center"/>
-
</Grid>
2、用户控件设置依赖属性
-
/// <summary> 绑定最小值 </summary>
-
public double MinValue
-
{
-
get { return (double)GetValue(MinValueProperty); }
-
set { SetValue(MinValueProperty, value); }
-
}
-
-
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
-
public static readonly DependencyProperty MinValueProperty =
-
DependencyProperty.Register("MinValue", typeof(double), typeof(BufferPlayControl), new PropertyMetadata(0.0, (d, e) =>
-
{
-
BufferPlayControl control = d as BufferPlayControl;
-
-
if (control == null) return;
-
-
//double config = e.NewValue as double;
-
-
}));
-
-
/// <summary> 绑定最大值 </summary>
-
public double MaxValue
-
{
-
get { return (double)GetValue(MaxValueProperty); }
-
set { SetValue(MaxValueProperty, value); }
-
}
-
-
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
-
public static readonly DependencyProperty MaxValueProperty =
-
DependencyProperty.Register("MaxValue", typeof(double), typeof(BufferPlayControl), new PropertyMetadata(100.0, (d, e) =>
-
{
-
BufferPlayControl control = d as BufferPlayControl;
-
-
if (control == null) return;
-
-
//double config = e.NewValue as double;
-
-
}));
-
-
/// <summary> 绑定最小偏移量 </summary>
-
public double SmallChange
-
{
-
get { return (double)GetValue(SmallChangeProperty); }
-
set { SetValue(SmallChangeProperty, value); }
-
}
-
-
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
-
public static readonly DependencyProperty SmallChangeProperty =
-
DependencyProperty.Register("SmallChange", typeof(double), typeof(BufferPlayControl), new PropertyMetadata(0.1, (d, e) =>
-
{
-
BufferPlayControl control = d as BufferPlayControl;
-
-
if (control == null) return;
-
-
//double config = e.NewValue as double;
-
-
}));
-
-
/// <summary> 设置当前播放值 </summary>
-
public double Value
-
{
-
get { return (double)GetValue(ValueProperty); }
-
set { SetValue(ValueProperty, value); }
-
}
-
-
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
-
public static readonly DependencyProperty ValueProperty =
-
DependencyProperty.Register("Value", typeof(double), typeof(BufferPlayControl), new PropertyMetadata(30.0, (d, e) =>
-
{
-
BufferPlayControl control = d as BufferPlayControl;
-
-
if (control == null) return;
-
-
//double config = e.NewValue as double;
-
-
}));
-
-
-
/// <summary> 设置当前缓冲值 </summary>
-
public double BufferValue
-
{
-
get { return (double)GetValue(BufferValueProperty); }
-
set { SetValue(BufferValueProperty, value); }
-
}
-
-
// Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
-
public static readonly DependencyProperty BufferValueProperty =
-
DependencyProperty.Register("BufferValue", typeof(double), typeof(BufferPlayControl), new PropertyMetadata(50.0, (d, e) =>
-
{
-
BufferPlayControl control = d as BufferPlayControl;
-
-
if (control == null) return;
-
-
//double config = e.NewValue as double;
-
-
}));
3、测试代码
测试代码UI部分:开始、暂停、继续和显示进度、缓冲进度
-
<GroupBox Header="缓冲播放进度条">
-
<StackPanel>
-
<wpfcontrollib:BufferPlayControl x:Name="control_bufferPlay"/>
-
<TextBlock x:Name="txt_persent"/>
-
<TextBlock Text="{Binding ElementName=control_bufferPlay,Path=Value}"/>
-
<Button Content="开始" Click="Button_Click"/>
-
<Button x:Name="btn_play" Content="暂停" Click="Button_Click_1"/>
-
</StackPanel>
-
</GroupBox>
测试代码后台逻辑:
点击播放代码部分
-
List<IBufferPlayEntity> bufferPlays = new List<IBufferPlayEntity>();
-
-
// Message:构造1000个测试数据
-
for (int i = 0; i < 1000; i++)
-
{
-
BufferPlayEntity entity = new BufferPlayEntity();
-
-
bufferPlays.Add(entity);
-
}
-
-
// Message:初始化控件
-
this.control_bufferPlay.MinValue = 0;
-
this.control_bufferPlay.Value = 0;
-
this.control_bufferPlay.BufferValue = 0;
-
this.control_bufferPlay.MaxValue = bufferPlays.Count;
-
-
// Message:开始缓冲引擎
-
BufferPlayEngine bufferPlayEngine = new BufferPlayEngine(bufferPlays);
-
-
bufferPlayEngine.RefreshCapacity(5);
-
-
bufferPlayEngine.Start();
-
-
Action<bool, int, int> action = (l, k, n) =>
-
{
-
Application.Current.Dispatcher.Invoke(() =>
-
{
-
if (l)
-
{
-
this.txt_persent.Text = "缓冲完成..";
-
}
-
else
-
{
-
string p = (Convert.ToDouble(k) * 100 / Convert.ToDouble(n)).ToString();
-
-
this.txt_persent.Text = "缓冲中.." + p + "%";
-
}
-
});
-
-
};
-
-
// Message:刷新播放进度
-
Task.Run(() =>
-
{
-
for (int i = 0; i < bufferPlays.Count; i++)
-
{
-
// Message:设置当前播放进度值
-
Application.Current.Dispatcher.Invoke(() =>
-
{
-
this.control_bufferPlay.Value = i;
-
});
-
-
// Message:检查当前是否已经暂停
-
while (true)
-
{
-
-
bool result = false;
-
-
Application.Current.Dispatcher.Invoke(() =>
-
{
-
result = this.btn_play.Content.ToString() == "暂停";
-
});
-
-
if (result) break;
-
-
Thread.Sleep(1000);
-
}
-
-
Thread.Sleep(100);
-
-
// Message:阻塞等待当前进度是否可以播放
-
bufferPlayEngine.GetWaitCurrent(l => l == bufferPlays[i], action);
-
-
}
-
-
});
-
-
// Message:刷新下载进度
-
Task.Run(() =>
-
{
-
while (true)
-
{
-
Thread.Sleep(100);
-
-
Application.Current.Dispatcher.Invoke(() =>
-
{
-
this.control_bufferPlay.BufferValue = bufferPlayEngine.GetBufferSize((int)this.control_bufferPlay.Value);
-
});
-
-
}
-
});
点击暂停或继续代码部分:
-
Button button = sender as Button;
-
-
button.Content = button.Content.ToString() == "暂停" ? "继续" : "暂停";
测试任务实体:继承任务抽象类基类或接口,实现一个随机等待1-2秒完成的方法
-
-
public class BufferPlayEntity : BufferPlayEntityBase
-
{
-
public int IsLoaded { get; set; }
-
-
Random random = new Random();
-
-
public override void DoStart()
-
{
-
Thread.Sleep(random.Next(1, 2) * 1000);
-
}
-
}
4、核心缓冲引擎:
BufferPlayEngine:
设置可播放容量:在播放过程中,播放阻塞后需要缓冲的容量
设置播放缓冲总量:为了节省性能,当达到当前播放容量时,停止继续缓冲
设置并行任务数量:多线程执行任务的并行数量
原理:
Start()方法:后台创建多个缓冲线程去根据当前播放的任务去执行缓冲任务,获取第一个没有下载的任务,当任务超过最大缓冲容量时不执行下载
GetWaitCurrent()方法:如果当前任务已经完成则直接返回,如果当前任务未完成则需要等待可执行播放数量Capacity设置的数量都下载完成时才取消阻塞返回要执行的任务;
GetBufferSize()方法:获取当前已经缓冲好的数量,用于更新缓冲区域进度条
-
/// <summary> 缓冲播放引擎 </summary>
-
public class BufferPlayEngine
-
{
-
/// <summary> 可播放容器量 </summary>
-
public int Capacity { get; set; } = 10;
-
-
/// <summary> 总缓冲容器量 </summary>
-
public int CapacityTotal { get; set; } = 10;
-
-
/// <summary> 同时下载的任务数量 </summary>
-
public int TaskCount { get; set; } = 5;
-
-
// Message:所有的文件列表
-
List<IBufferPlayEntity> _entitys = new List<IBufferPlayEntity>();
-
-
// Message:当前播放的节点
-
IBufferPlayEntity _current;
-
-
public BufferPlayEngine(List<IBufferPlayEntity> entitys)
-
{
-
_entitys = entitys;
-
-
_current = entitys.First();
-
}
-
-
/// <summary> 刷新缓冲数量 </summary>
-
public void RefreshCapacity(int count)
-
{
-
// Do:可播放队列设置15s
-
this.Capacity = count * 5;
-
-
////Do:后台缓存最多队列设置成5分钟
-
this.CapacityTotal = count * 2 * 10;
-
}
-
-
CancellationTokenSource cts = new CancellationTokenSource();
-
-
Semaphore _semaphore1 = new Semaphore(1, 1);
-
/// <summary> 开始播放 </summary>
-
public void Start()
-
{
-
if (cts != null)
-
{
-
cts.Cancel();
-
_semaphore1.WaitOne();
-
}
-
-
cts = new CancellationTokenSource();
-
-
// Message:启动当前位置的顺序下载任务
-
Task.Run(() =>
-
{
-
// Message:并行运行
-
ParallelLoopResult result = Parallel.For(0, this.TaskCount, k =>
-
{
-
while (true)
-
{
-
-
if (cts.IsCancellationRequested) break;
-
-
int index = this._entitys.FindIndex(l => l == _current);
-
-
var downs = _entitys.Skip(index).Take(this.CapacityTotal).Where(l => l.IsLoaded == 0);
-
-
// Message:超出最大下载缓存数量则等待
-
if (downs == null || downs.Count() == 0)
-
{
-
Thread.Sleep(1000);
-
continue;
-
}
-
-
downs.FirstOrDefault()?.Start();
-
-
}
-
}
-
);
-
-
_semaphore1.Release();
-
-
}, cts.Token);
-
}
-
-
/// <summary> 停止引擎 </summary>
-
public void Stop()
-
{
-
if (cts != null)
-
{
-
cts.Cancel();
-
}
-
-
flag = false;
-
}
-
-
bool flag = true;
-
-
-
Semaphore _semaphore = new Semaphore(1, 1);
-
-
/// <summary> 获取下好的文件 返回null则需要等待 </summary>
-
public IBufferPlayEntity GetWaitCurrent(Predicate<IBufferPlayEntity> match, Action<bool, int, int> action)
-
{
-
var result = this._entitys.Find(match);
-
-
int now = this._entitys.FindIndex(match);
-
-
_current = result;
-
-
if (result.IsLoaded == 2)
-
{
-
return result;
-
}
-
else
-
{
-
// Message:停止上一个获取任务
-
flag = false;
-
-
_semaphore.WaitOne();
-
-
flag = true;
-
-
var waitCache = _entitys.Skip(now).Take(this.Capacity).ToList();
-
-
while (!waitCache.TrueForAll(l => l.IsLoaded == 2))
-
{
-
if (!flag)
-
{
-
_semaphore.Release();
-
return null;
-
}
-
-
Thread.Sleep(500);
-
-
action(false, waitCache.FindAll(l => l.IsLoaded == 2).Count, waitCache.Count);
-
}
-
-
action(true, waitCache.FindAll(l => l.IsLoaded == 2).Count, waitCache.Count);
-
-
_semaphore.Release();
-
return result;
-
}
-
}
-
-
/// <summary> 获取下好的文件 返回null则需要等待 </summary>
-
public IBufferPlayEntity GetWaitCurrent(int index, Action<bool, int, int> action)
-
{
-
var result = this._entitys[index];
-
-
return this.GetWaitCurrent(l => l == result, action);
-
}
-
-
/// <summary> 获取当前缓存完的位置 </summary>
-
public int GetBufferSize(Predicate<IBufferPlayEntity> match)
-
{
-
int index = this._entitys.FindIndex(l => l == _current);
-
-
return this.GetBufferSize(index);
-
}
-
-
/// <summary> 获取当前缓存完的位置 </summary>
-
public int GetBufferSize(int index)
-
{
-
var isdown = _entitys.Skip(index).LastOrDefault(l => l.IsLoaded == 2);
-
-
if (isdown == null) return 0;
-
-
return this._entitys.FindIndex(l => l == isdown);
-
}
-
-
/// <summary> 清理缓存数据 </summary>
-
public void Clear()
-
{
-
-
}
-
-
// Message:是否是向前播放
-
bool _isForward = true;
-
-
/// <summary> 反向播放 </summary>
-
public void RefreshPlayMode(bool forward)
-
{
-
if (_isForward = forward) return;
-
-
_isForward = forward;
-
-
_entitys.Reverse();
-
}
-
}
缓冲引擎任务执行接口和抽象基类
IBufferPlayEntity:
-
/// <summary> 缓冲任务接口 </summary>
-
public interface IBufferPlayEntity
-
{
-
/// <summary> 是否执行完成 </summary>
-
int IsLoaded
-
{
-
get;
-
set;
-
}
-
-
/// <summary> 开始任务 </summary>
-
void Start();
-
}
BufferPlayEntityBase:
-
/// <summary> 缓冲任务抽象基类 </summary>
-
public abstract class BufferPlayEntityBase : IBufferPlayEntity
-
{
-
/// <summary> 执行状态 1=正在执行 2=执行完成 0=未执行 -1=执行错误 </summary>
-
public int IsLoaded { get; set; }
-
-
public void Start()
-
{
-
this.IsLoaded = 1;
-
-
try
-
{
-
this.DoStart();
-
}
-
catch (Exception ex)
-
{
-
-
Debug.WriteLine(ex);
-
-
this.IsLoaded = -1;
-
}
-
-
this.IsLoaded = 2;
-
}
-
-
public abstract void DoStart();
-
}
GitHub:
示例:WPF中Slider控件封装的缓冲播放进度条控件的更多相关文章
- Photoshop和WPF双剑配合,打造炫酷个性的进度条控件
现在如果想打造一款专业的App,UI的设计和操作的简便性相当重要.UI设计可以借助Photoshop或者AI等设计工具,之前了解到WPF设计工具Expression Blend可以直接导入PSD文件或 ...
- [转载]ExtJs4 笔记(8) Ext.slider 滚轴控件、 Ext.ProgressBar 进度条控件、 Ext.Editor 编辑控件
作者:李盼(Lipan)出处:[Lipan] (http://www.cnblogs.com/lipan/)版权声明:本文的版权归作者与博客园共有.转载时须注明本文的详细链接,否则作者将保留追究其法律 ...
- ExtJs4 笔记(8) Ext.slider 滚轴控件、 Ext.ProgressBar 进度条控件、 Ext.Editor 编辑控件
本篇要登场的有三个控件,分别是滚轴控件.进度条控件和编辑控件. 一.滚轴控件 Ext.slider 1.滚轴控件的定义 下面我们定义三个具有代表意义滚轴控件,分别展示滚轴横向.纵向,以及单值.多值选择 ...
- WPF 控件库——仿制Windows10的进度条
WPF 控件库系列博文地址: WPF 控件库——仿制Chrome的ColorPicker WPF 控件库——仿制Windows10的进度条 WPF 控件库——轮播控件 WPF 控件库——带有惯性的Sc ...
- 在DevExpress GridControl中添加进度条控件 z
首先可以使用 DevExpress GridControl 自带的进度条控件. 但是我要用一个方法来设置所有的单元格进度,而不是每个单元格都要设置一遍,同时我想要根据进度值不同,进度条显示不同的颜色. ...
- C# 根据BackgroundWoker异步模型和ProgressBar控件,自定义进度条控件
前言 程序开发过程中,难免会有的业务逻辑,或者算法之类产生让人能够感知的耗时操作,例如循环中对复杂逻辑处理;获取数据库百万乃至千万级数据;http请求的时候等...... 用户在使用UI操作并不知道程 ...
- CProgressCtrl进度条控件实现进度滚动效果
关于CProgressCtrl 控件的基本操作网上有很多资料,可我想实现进度条中进度滚动效果,即很多时候程序出现的等待或启动画面,如下图: 实现这个效果的函数为SetMarquee(_In_ BOOL ...
- HslControls组件库 工业控件库 曲线控件 时间控件 管道控件 温度计控件 阀门控件 传送带控件 进度条控件 电池控件 数码管控件等等
本篇博客主要对 HslControls 组件做一个大概的总览介绍,更详细的内容可以参照页面里的子链接,还有github上的源代码,然后进行相关的学习,和使用. Prepare 先从nuget下载到组件 ...
- iOS:进度条控件的详细使用
进度条控件:UIProcessView:UIView 功能:顾名思义,用来显示下载进度或者传输数据进度. 属性: @property(nonatomic) UIProgressViewStyl ...
随机推荐
- 在知识爆炸的年代如何学习,避免成为PPT架构师
计算机的发展大体遵循摩尔定律,IT要学的东西越来越多,感觉无从下手 然后发现许多人,专门喜欢说这些名词概念装高大上,脱离一线开发,技术跟风盲目崇拜新的骚东西,比如docker,k8s,微服务,open ...
- 枚举ENUM的tostring() valueof()name()和values()用法
从jdk5出现了枚举类后,定义一些字典值可以使用枚举类型; 枚举常用的方法是values():对枚举中的常量值进行遍历; valueof(String name) :根据名称获取枚举类中定义的常量值; ...
- AAC的RTP封装中的AU头分析
解码器收到一个RTP的AAC流,发现RTP流里的音频里带有4个字节AU头,然后才是AAC的ADTS头. 这种情况之前已经出现过多次,每次我们都告知对方,不要往AAC前面加AU头,解码器不支 ...
- js日期增加或减少一天
想自己写一个日期的加减方法,但是涉及到每个月天数的判断,如果是2月份的话,还要涉及到闰年的判断,有些复杂,其实只要调用Date对象的setDate()函数就可以了,具体方法如下: function a ...
- node 单线程异步非阻塞
链接:http://www.runoob.com/nodejs/nodejs-callback.html 首先什么是单线程异步非阻塞? 单线程的意思整个程序从头到尾但是运用一个线程,程序是从上往下执行 ...
- Java多线程编程核心技术-第7章-拾遗增补-读书笔记
第 7 章 拾遗增补 本章主要内容 线程组的使用. 如何切换线程状态. SimpleDataFormat 类与多线程的解决办法. 如何处理线程的异常. 7.1 线程的状态 线程对象在不同的运行时期有不 ...
- vue大文件上传插件选哪个好?
文件夹数据库处理逻辑 public class DbFolder { JSONObject root; public DbFolder() { this.root = new JSONObject() ...
- 洛谷P1230智力大冲浪 题解
题目描述 小伟报名参加中央电视台的智力大冲浪节目.本次挑战赛吸引了众多参赛者,主持人为了表彰大家的勇气,先奖励每个参赛者m元.先不要太高兴!因为这些钱还不一定都是你的?!接下来主持人宣布了比赛规则: ...
- helm原理
Helm: helm就相当于Linux的包管理工具yum,但它管理的程序包是一些打包好的清单文件. 其核心术语: Chart:一个helm程序包,它里面可理解为,包含了一下定义Pod的清单文件,这些清 ...
- const 变量在多个文件共享,如何验证两种不同的方式下,编译器是否会在多个文件下建立多个副本
对于const变量多个文件共享,当我们不希望编译器为每个文件分别生成独立的变量,而是像非常量对象一个,一处定义,多处声明并使用. 解决办法是,对于const变量,不管是声明还是定义都添加extern关 ...