专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Silverlight

Silverlight性能有关问题

发布时间:2011-06-27 20:15:46 文章来源:www.iduyao.cn 采编人员:星星草
Silverlight性能问题
开发平台:VS2010,
SL版本:4.0
硬件环境:双核2.4,2G内存
操作系统:Server2008


  我们目前程序只做完了界面,没人任何的逻辑处理,可是随便打开一个页面,明显比IE慢很多,总有延迟(页面上未做任何处理),而且内存消耗也大,换了几台电脑测试也是这样。现在不得不担心将来系统应用后,多用户同时使用的效率问题,
现在矛盾了,不知道该不该继续用SL做下去.....

------解决方案--------------------
这是不应该发生的事,说的太笼统,实际上逻辑处理内存占用最少,动画机制占用内存最多,代码结构不好会造成性能下降,在一般情况下,要完成同样功能,它与桌面程序时一样的,因为silverlight实用客户端代码。你的配置不是很低,根据我的经验应该不会出现你说的那样,虽好晒晒你的代码,才能知道具体原因。
------解决方案--------------------
不知道你怎么测试的项目感觉速度慢,我也在使用Silverlight做企业级项目,速度方面很理想哦。
对于项目优化方面还有很多技巧,可以参考这个系列,来优化项目。

WPF/Silverlight深度解决方案

http://www.silverlightchina.net/html/zhuantixilie/getstart/2009/1207/312.html
------解决方案--------------------
我在开发的项目的页面都是用的 Page ,没有用 UserControl ,UserControl 只用作部分控件,感觉客户端的性能还是可以的。

但是前公司的项目中页面都是使用 UserControl , 客户端性能就很低下,不知这会不会是一个重要原因。
------解决方案--------------------
代码已经清除了,这里写出大意如下:

VB.NET code

<UserControl x:Class="SLmadamingAdvanced.uc_random_draw"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    >
    <Grid x:Name="LayoutRoot" Background="White" ShowGridLines="True" >
        <Grid.RowDefinitions>
            <RowDefinition Height="35"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal" >
            <Button x:Name="button_start" Content="开始绘图" Width="80" Height="25" Margin="5" Click="button_start_Click" ></Button>
            <Button x:Name="button_stop" Content="结束绘图" Width="80" Height="25" Margin="5" Click="button_stop_Click"  ></Button>
        </StackPanel>
        <Canvas x:Name="canvas_draw" Width="400" Height="400" Grid.Row="1"></Canvas>
    </Grid>
</UserControl>
Partial Public Class uc_random_draw
    Inherits UserControl
#Region " 自定义"
#Region " - 内部成员"
    Private _draw_ok As Boolean = True
    Private n As New Random
    Private _radius As Double

    Private _r As New SolidColorBrush(Colors.Red)
    Private _g As New SolidColorBrush(Colors.Green)
    Private _b As New SolidColorBrush(Colors.Blue)
    Private _black As New SolidColorBrush(Colors.Black)

#End Region

#Region " - 方法"
    Private Sub random_draw()
        Dim e As Ellipse
        Dim i As Integer

        For i = 0 To Int16.MaxValue
            e = New Ellipse

            e.Width = n.Next Mod 30 + 1
            e.Height = e.Width
            Select Case n.Next Mod 3
                Case 0
                    e.Fill = _r
                Case 1
                    e.Fill = _g
                Case 2
                    e.Fill = _b
            End Select
            e.Stroke = _black

            canvas_draw.Children.Add(e)

            e.SetValue(Canvas.LeftProperty, CDbl(n.Next Mod 380))
            e.SetValue(Canvas.TopProperty, CDbl(n.Next Mod 380))

            If Not _draw_ok Then
                Exit For
            End If

        Next

    End Sub
#End Region
#End Region
    Public Sub New()

        InitializeComponent()

    End Sub

    Private Sub button_start_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        _draw_ok = True
        random_draw()
    End Sub


    Private Sub button_stop_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
        _draw_ok = False
    End Sub
End Class
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: