Silverlight数据异步通信事例

深度解析微软SilverLight富互联网应用开发平台 你可能会问:都2025年了,谁还会用Silverlight?确实,官方早在2021年就终止支持了。但它留下的遗产却深远影响着今天的开发范式:✅声明式UI→ XAML 影响了 SwiftUI、Jetpack Compose✅数据绑定 + MVVM→ 成为现代前端框架标配✅WASM沙箱理念→ 与Silverlight插件模型惊人相似✅自适应流媒体→ HLS/DASH协议的先行者✅组件化架构→ 早于Angular/React十年提出。 阅读详情

 

今天无聊,在网上瞎逛,突然看到一些关于silverlight的内容。嘿嘿,正好趁自己有空也写个小程序玩玩。

功能就是点击用户名,利用WebClient异步获取服务器上用户的信息(图片和介绍) 界面运行效果如下。

 

 


 

 

 

 

 

 

开始本来是用silverlight Beta1完成的,后来越做越发现很多功能和属性用着麻烦也不太好
 
用了,最后干脆就改成了Beta2了,毕竟是最新版,果然用着舒服些啊。 整个功能完成
 
的比较顺利,当中也遇到了几个稍微麻烦点
­
的问 题。比如在Silverlight项目中图片路径赋值的问题。设置图片Source路径必须是ImageSource,我的是
­
"jay.jpg"路径怎么转?在Api里翻了半天,也没发现。最后到网上查了下, 网上搜了半天没个结果,最后瞎折腾了半
 
天用获取网络资源的方式,竟然成功了。方式:
­
new BitmapImage(new Uri(System.Windows.Browser.HtmlPage.Document.DocumentUri, "Images/a.jpg");
 
不过,这个方式不好的地方就是不能把图片放入Silverlight项目中打包,只能把图片转移到Web Application
­
里去了。
­
下面是Silverlight项目xaml部分源码了。
­
­
<UserControl x:Class="SilverlightTravel.NetWebClient"
    Width="600" Height="300" Loaded="UserControl_Loaded">
    <Grid x:Name="LayoutRoot" Background="WhiteSmoke" ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="30"></RowDefinition>
            <RowDefinition Height="150"></RowDefinition>
            <RowDefinition Height="200"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <TextBlock Text="请选择人物查看介绍" Grid.Column="0" Grid.Row="0"></TextBlock>
        <ListBox Grid.Column="0" x:Name="lstMusicer" Grid.Row="1" Width="200" HorizontalAlignment="Left" SelectionChanged="lstMusicer_SelectionChanged">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding UserName}" Height="35"></TextBlock>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <Image x:Name="imgPerson" HorizontalAlignment="Left" Grid.Row="1" Grid.Column="1"></Image>
        <MediaElement x:Name="mePlayer" HorizontalAlignment="Left" Source="video/" Grid.Row="2" Grid.Column="2" Height="50" Width="50"></MediaElement>
        <TextBlock x:Name="txtIntroduce"   Grid.Row="2" Grid.Column="1" Margin="30 50 " Grid.ColumnSpan="2"></TextBlock>
        <Button Height="50" VerticalAlignment="Top" Margin="10 " Width="120" Grid.Row="2" Grid.Column="0" Background="Red" Content="数据异步通信"></Button>
    </Grid>
</UserControl>
基于Silverlight与C#后台的文件上传功能完整实现 也许有一天,Silverlight 会被彻底遗忘。但今天我们讨论的这些设计理念——状态本地缓存断点续传机制前后端异步协作文件安全检测资源分级管控——仍然活跃在现代 Web 开发的各个角落。无论是 React + Axios + Spring Boot,还是 Blazor + SignalR + MinIO,你会发现底层逻辑惊人地相似。所以啊,与其纠结某个框架是否“已死”,不如专注于提炼那些跨越时代的核心模式。 阅读详情

相关推荐

深入浅出Silverlight:C#与Web开发实战解析

虽然提供了基本的播放功能,但实际项目中往往需要构建更美观、功能更丰富的播放器界面。以下是一个自定义播放器的界面结构示例:<Button Content="播放" Click="Play_Click"/><Button Content="暂停" Click="Pause_Click"/><Button Content="停止" Click="Stop_Click"/>C# 事件处理代码:功能扩展建议:添加播放进度条并实现拖动跳转功能。支持字幕加载与切换。

weixin_31641077的博客 836

一步一步学Silverlight 2系列(12):数据与通信之WebClient

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://terrylee.blog.51cto.com/342737/67249 ...

weixin_34138139的博客 320

of_graph_get_remote_port

isp { compatible = "isp"; core@0 { id = <0>; ports { #address-cells = <1>; #size-cells = <0>; port@0 { reg = <0>; ...

wmzjzwlzs的专栏 1170

Silverlight中调用Web Service

Silverlight应用程序中有一些基本功能适用于所有HTTP和HTTPS通信,如下: 1、始终允许同域调用。 2、如果正确配置了承载Web服务的Web服务器,则支持跨域调用。 3、所有通信都是异步的。 4、仅支持GET和POST调用。 5、支持大多数标准请求标头和所有的自定义请求标头,跨域请求的跨域策略文件中必须允许有标头。 6、只有"00确定"和"404未找到"状态码可以用。

GIS天下 1109

望获实时Linux与国产芯片协同:打造LinuxCNC数控机床的全栈国产化方案

本文探讨了如何通过望获实时Linux与飞腾、龙芯等国产芯片的深度协同,为LinuxCNC数控机床打造全栈国产化方案。望获实时Linux通过中断隔离等核心技术,提供亚微秒级确定性响应,解决了传统Linux系统实时性不足的痛点,使LinuxCNC得以稳定驱动高精度机床。该方案实现了从硬件、操作系统到应用软件的全栈自主可控,为工业控制领域提供了高性能、可定制的国产化选择。

weixin_29291069的博客 664

ADS入门学习笔记——射频振荡器的设计

振荡器是射频系统中的基本部件之一,可以将直流功率转换为射频功率,在特定的频率点建立起稳定的正弦振荡,成为所需的射频信号源。

weixin_42126696的博客 8961

书评:《Introducing Silverlight 2》 – 第十章

第十章:Building Connected Application with Silverligth(建立连接的Silverlight应用程序) 在前些章“愉快”的阅读后,本章把偶一个但是疏忽了的思考给偶当头一棒。Silverlight是运行于客户端的软件,也就是它的运行所消耗的CPU资源是用浏览器访问客户端的时候产生的客户端CPU资源。 而在大多数情况下,客户端访问数据库的可能

leiyangcl的专栏 520

PSI5协议技术文档与驱动开发指南

• 供电与数据复用:ECU通过双绞线为传感器提供稳压(典型值5V-11V),同时检测线路电流变化实现数据传输。• 同步信号:ECU发送3.5V电压脉冲(上升沿触发传感器响应),用于时序同步。• 安全气囊:PSI5-P模式实现多碰撞传感器同步采样(响应时间<10ms)• CRC-3(3位):ASIL-B以上功能安全要求(如动力总成传感器)• 奇偶校验(1位):适用于低安全等级场景(如PSI5-P10P模式)• 典型应用:PSI5-P(并行总线)、PSI5-U(通用总线)

u012733413的博客 2876

Silverlight商业应用程序开发---从服务器中获取数据之一

异步通信 在Silverlight中所有与服务器间的通信都是异步执行的。因此需要熟悉异步编程。典型的编程模式包括发起一个对服务器的调用,然后等待事件引发通知调用完成。调用在后台线程执行,一旦完成就立即返回,从而避免了UI因该方法的调用而阻塞。一般说来,如果异步调用在完成时引发事件,该事件通常都会在UI线程引发,更      异步通信   在Silverlight中所有与服务器间的

Neo的专栏 1571

YOLOv8模型轻量化实战:基于稀疏化剪枝与L1正则化的高效目标检测模型优化-附源码

本文提出一种YOLOv8轻量化方案,通过L1正则化稀疏化训练和动态阈值通道剪枝,在边缘计算场景中优化模型性能。方案分三步:首先通过L1正则诱导权重稀疏化并动态衰减系数;然后基于BN层权重统计进行通道剪枝,保留80%关键通道;最后对剪枝模型微调恢复精度。在COCO128数据集上验证,模型体积压缩40%,推理速度提升2.3倍,mAP仅下降0.4%,实现了精度与效率的平衡。该方案为移动端部署提供了可行的轻量化技术路径。

m0_64661770的博客 481

【PCIe 总线及设备入门学习专栏 6.2 -- PCIe VDM (Vendor Defined Messages)】

在PCIe协议中,Vendor Defined Messages (VDMs) 是一种允许厂商定义和传输特定功能的消息类型。这种机制扩展了标准 PCIe 消息的功能,可以用于实现供应商自定义的功能,例如固件更新、设备配置和诊断信息传输。PCIe VDM 是通过实现的,它遵循 PCIe 协议栈的结构,包括事务层、数据链路层和物理层。

CodingCos的博客 1914

(12):Silverlight 2 数据与通信之WebClient

概述Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, Ironpython,对JSON、Web Service、WCF以及Sockets的支持等一系列新的特性。《一步一步学Silverlight 2系列》文章带您快速进入Silverlight 2

~飞 鸟 (*^__^*) 天 堂~ 478

从零构建法律案例数据库:Python爬虫实战与法律文本挖掘全攻略

在当今数字化浪潮席卷全球的背景下,法律行业正经历着前所未有的变革。法律案例数据库作为法律大数据的重要组成部分,已经成为法律从业者、研究人员、法学院学生乃至企业法务部门的必备工具。然而,商业法律数据库如北大法宝、威科先行、LexisNexis等往往价格不菲,且数据访问受限。对于个人研究者或小型机构而言,构建一个定制化的法律案例数据库不仅能节省成本,更能根据特定研究需求灵活调整数据结构。

2201_76125261的博客 549

Silverlight之重

上期笔者刚提出Silverlight之亲,本期就要讨论silverlight之重?请大家不要觉得奇怪,架构的轻与重永远都是相对而言,虽然Silverlight相对于传统C/S架构有更加轻型的运行时环境,但相较于Html+JavaScript等传统B/S架构确实具有更加庞大的基础类

Hurry的专栏 2683

【100%通过率】华为OD机试真题 C++ 实现【打印机队列】【2022.11 Q4 新题】

有5台打印机打印文件,每台打印机有自己的待打印队列。因为打印的文件内容有轻重缓急之分,所以队列中的文件有1~10不同的代先级,其中数字越大优先级越高。打印机会从自己的待打印队列中选择优先级最高的文件来打印。如果存在两个优先级一样的文件,则选择最早进入队列的那个文件。现在请你来模拟这5台打印机的打印过程。

MISAYAONE的博客 9955

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

(转)Silverlight 之重

Silverlight 之重 TheEdge推荐[2011-2-14] 出处:infoQ Silverlight轻舞飞扬 作者:吴磊 上期笔者刚提出Silverlight之轻,本期就要讨论silverlight之重?请大家不要觉得奇怪,架构的轻与重永远都是相对而 言,虽然Silverlight相对于传统C/S架构有更加轻型的运行时环境,但相较于Html+Java...

diaoliti2465的博客 220

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

使用 Silverlight 2 和 WCF 构建服务驱动的应用程序

John Papa 代码下载位置: SLDataServices2008_09a.exe (234 KB) 在线浏览代码 本专栏基于 Silverlight 2 的 Beta 2 版本。文中的所有信息均有可能发生变更。 下载本文中所用的代码: DataPoints2008_09a.exe (414 KB) 浏览在线代码 目录 示例应用程序 跨域通信 Silv

北京动点飞扬软件 2108

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

一步一步学Silverlight 2系列(12):数据与通信之WebClien

概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, Ironpython,对JSON、Web Service、WCF以及Sockets的支持等一系列新的特性。《一步一步学Silverlight 2系列》文章带您快速进入Silv...

weixin_33699914的博客 94

一步一步学Silverlight 2系列(13):数据与通信之WebRequest

概述 Silverlight 2 Beta 1版本发布了,无论从Runtime还是Tools都给我们带来了很多的惊喜,如支持框架语言Visual Basic, Visual C#, IronRuby, Ironpython,对JSON、Web Service、WCF以及Sockets的支持等一系列新的特性。《一步一步学Silverlight 2系列》文章带您快速进入Silverlight 2开发...

weixin_30809333的博客 68

silverlight4数据与通信之WebClient详解

编写一个简单的示例,在该示例中,选择一本书籍之后,我们通过 Web Client 去查询书籍的价格,并显 示出来,最终的效果如下: 编写界面布局,XAML 如下: <UserControl x:Class="sample.s12" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation...

weixin_30480075的博客 129
上一篇: Struts Validator 实例(基础)
下一篇: 堆栈、队列与自动排序集合简单测试事例
tcspace
博客等级 码龄20年 12粉丝 55原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值