Click here to Skip to main content
15,899,313 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello all. I have a small problem. I need to refresh my data every 5mn with a timer, i call my function GetList(). On my computer, i have any problem. My screen is refresh, without seeing anything. But, on an another PC, i have a "small flash" (the list disppears and appears but it's 1/2 seconde) at the time of refresh. I don't understand why : my 2 computers are Windows 10, same processor, same RAM memory.
Which is even stranger, on my computer, this phenomenon appears randomly every 5 or 10 refresh, for the same datas (same quantity of rows SQL). But, on another PC, this "flash" seeing to all refresh.

Do i need improve my code ? How ? Why i have this phenomenon ?

My XAML Code :

C#
<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="clr-namespace:Plutus" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="Plutus.MainWindow"
        Title="Plutus" Height="523.725" Width="898" WindowStartupLocation="CenterScreen" WindowState="Maximized" Loaded="Window_Loaded" Icon="PlutusIcone.ico">
    <Window.Resources>
        <Style TargetType="ScrollBar">
            <Setter Property="Width" Value="35"/>
        </Style>
    </Window.Resources>
    <Grid>
        <Grid.Background>
            <ImageBrush ImageSource="Images/FondPlutus.png" Stretch="UniformToFill" />
        </Grid.Background>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="0.03*" />
            <RowDefinition Height="0.05*" />
            <RowDefinition Height="0.05*" />
            <RowDefinition Height="0.87*"/>
            <RowDefinition Height="0.03*" />
        </Grid.RowDefinitions>
        <Rectangle Fill="White" Grid.Column="1" Grid.Row="0" />
        <Label Grid.Row="0" Grid.Column="1" Background="White" Content="LISTE" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="18" FontWeight="Bold"/>
        <Label Grid.Row="0" Grid.Column="0" Background="WHite" />
        <Image Source="Images/UNE.jpg" HorizontalAlignment="Left" Grid.Row="0" Grid.Column="0" />
        <Label Grid.Row="0" Grid.Column="3" Background="WHite" />
        <Image Source="Images/_H.jpg" HorizontalAlignment="Right" Grid.Row="0" Grid.Column="2" />
        <!--<Button Visibility="{Binding strShowMenu}" Name="btnParamsAffichage" Content="Paramètres" HorizontalAlignment="Left" Width="100" Grid.Column="0" Grid.Row="1" Background="#b2c9ef" Click="btnParamsAffichage_Click"  />-->
        <!--<Button Visibility="{Binding strShowMenu}" Name="btnAttribution" Content="Attribution" HorizontalAlignment="Right" Width="100" Grid.Column="1" Grid.Row="1" Background="#b2c9ef" Click="btnAttribution_Click"  />-->
        <Image Visibility="{Binding strShowMenu}"  Name="btnParamsAffichage" HorizontalAlignment="Left" Width="100" Grid.Column="0" Grid.Row="2" MouseLeftButtonUp="btnParamsAffichage_Click">
            <Image.Style>
                <Style TargetType="{x:Type Image}">
                    <Setter Property="Source" Value="Images/ParametresAffichage.png"/>
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Source" Value="Images/ParametresAffichageHover.png"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Image.Style>
        </Image>
        <Label FontSize="28" FontWeight="Bold" Grid.Row="2" Content="{Binding strFiltres}" Foreground="White" Margin="100,0, 0,0" VerticalAlignment="Center" />
        <Image Name="btnAttribution" HorizontalAlignment="Right" Width="100" Grid.Column="2" Grid.Row="2" MouseLeftButtonUp="btnAttribution_Click">
            <Image.Style>
                <Style TargetType="{x:Type Image}">
                    <Setter Property="Source" Value="Images/BarCode.png"/>
                    <Style.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Source" Value="Images/BarCodeHover.png"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </Image.Style>
        </Image>
        <Label FontSize="28" FontWeight="Bold" Foreground="White" Content="{Binding strSelection}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" />
        <ScrollViewer VerticalScrollBarVisibility="Auto" Grid.Row="3" Grid.ColumnSpan="3">
            <ItemsControl VerticalAlignment="Top" x:Name="lvDataBinding" HorizontalContentAlignment="Stretch" BorderThickness="0" Margin="10" Grid.Row="3" Background="{x:Null}" ItemsSource="{Binding LstOperations}" Foreground="White">
            <ItemsControl.ItemTemplate>
                <!--<DataTemplate DataType="{x:Type local:CL_Operation}">-->
                    <DataTemplate>
                        <Border BorderBrush="White" BorderThickness="1" CornerRadius="3" Margin="0,3" Grid.ColumnSpan="0" Background="Transparent" HorizontalAlignment="Left" VerticalAlignment="Top">
                        <Grid Width="{Binding strWidth}" Height="60" Background="Transparent" Margin="0,1">
                            <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="0.05*" />
                                    <ColumnDefinition Width="0.09*" />
                                    <ColumnDefinition Width="0.1*" />
                                    <ColumnDefinition Width="0.12*" />
                                    <ColumnDefinition Width="0.1*" />
                                    <ColumnDefinition Width="0.1*" />
                                    <ColumnDefinition Width="0.1*" />
                                    <ColumnDefinition Width="0.04*" />
                                    <ColumnDefinition Width="0.04*" />
                                    <ColumnDefinition Width="0.04*" />
                                    <ColumnDefinition Width="0.04*" />
                                    <ColumnDefinition Width="0.06*" />
                                </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                <RowDefinition />
                                 <RowDefinition />
                                 <RowDefinition />
                                </Grid.RowDefinitions>
                                <UniformGrid Tag="{Binding strRueck}" Background="{Binding scbBackColor}" Grid.Column="0" Grid.Row="0" Grid.RowSpan="4" MouseLeftButtonUp="ClickRowOf" >
                                    <UniformGrid.Style>
                                        <Style TargetType="{x:Type UniformGrid}">
                                            <Style.Triggers>
                                                <Trigger Property="IsMouseOver" Value="False">
                                                    <Setter Property="Opacity" Value="1"></Setter>
                                                </Trigger>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter Property="Opacity" Value="0.8"></Setter>
                                                </Trigger>
                                            </Style.Triggers>
                                        </Style>
                                    </UniformGrid.Style>
                                    <TextBlock Text="{Binding strPriorite}" FontSize="36" Foreground="Red" HorizontalAlignment="Center" VerticalAlignment="Center" FontWeight="Bold"/>
                                </UniformGrid>
                                <UniformGrid  Grid.Column="0" Grid.Row="4" Grid.RowSpan="2" Background="{Binding scbBackColor}">
                                    <TextBlock Text="{Binding strSsSect}" FontSize="14" Foreground="Black" HorizontalAlignment="Center" VerticalAlignment="Bottom" FontWeight="Bold" />
                                </UniformGrid>
                                <UniformGrid  Grid.Column="1" Grid.Row="0" Grid.RowSpan="6">
                                <TextBlock Text="{Binding strRetardAvanceText}" FontSize="28" Foreground="{Binding scbColorRetardAvance}" FontWeight="Bold" HorizontalAlignment="Center" VerticalAlignment="Center" />
                            </UniformGrid>
                            <UniformGrid  Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="2" Grid.RowSpan="4">
                                <UniformGrid.Style>
                                    <Style TargetType="{x:Type UniformGrid}">
                                        <Style.Triggers>
                                            <Trigger Property="IsMouseOver" Value="true">
                                                <Setter Property="Background" Value="Gray"/>
                                            </Trigger>
                                        </Style.Triggers>
                                    </Style>
                                </UniformGrid.Style>
                                    <TextBlock Tag="{Binding strRueck}" Foreground="{Binding scbColorNumOfOp}" Text="{Binding strNoOfOp}" FontSize="26" FontWeight="Bold" MouseLeftButtonUp="ClickNoOfOp"/>
                            </UniformGrid>
                            <UniformGrid  Grid.Column="2" Grid.Row="4" Grid.RowSpan="2" Grid.ColumnSpan="3">
                                <TextBlock Text="{Binding strDescriptionOp}" FontSize="14" Foreground="White"/>
                            </UniformGrid>
                            <UniformGrid Grid.Column="4" Grid.Row="0" Grid.RowSpan="2">
                                <TextBlock Text="{Binding strNoArticle}" FontSize="14" Foreground="White" FontWeight="Bold"/>
                            </UniformGrid>
                            <UniformGrid  Grid.Column="4" Grid.Row="2" Grid.RowSpan="2">
                                <TextBlock Text="{Binding strDateFormatee}" FontSize="14" Foreground="White" FontWeight="Bold"/>
                            </UniformGrid>
                            <UniformGrid Grid.Column="5" Grid.Row="0" Grid.RowSpan="2">
                                <TextBlock Text="{Binding strPcesPoste}" FontSize="14" Foreground="White"/>
                            </UniformGrid>
                            <UniformGrid  Grid.Column="5" Grid.Row="2" Grid.RowSpan="2">
                                <TextBlock Text="{Binding strTpsPoste}" FontSize="14" Foreground="White"/>
                            </UniformGrid>
                            <UniformGrid  Grid.Column="6" Grid.Row="0" Grid.RowSpan="2">
                                <TextBlock Text="{Binding strTempsPoste}" FontSize="14" Foreground="White"/>
                            </UniformGrid>
                            <UniformGrid  Grid.Column="6" Grid.Row="2" Grid.RowSpan="2">
                                <TextBlock Text="{Binding strClient}" FontSize="14" Foreground="White"/>
                            </UniformGrid>
                            <UniformGrid  Grid.Column="5" Grid.Row="4" Grid.RowSpan="2" Grid.ColumnSpan="3">
                                <TextBlock Text="{Binding strTypeOp}" FontSize="14" Foreground="White"/>
                            </UniformGrid>
                            <UniformGrid  Grid.Column="9" Grid.Row="4" Grid.RowSpan="2">
                                <TextBlock Text="{Binding strAuart}" FontSize="12" Foreground="White" FontWeight="Bold"/>
                            </UniformGrid>
                            <UniformGrid  Grid.Column="7" Grid.Row="0" Grid.RowSpan="4">
                                    <Image ToolTip="{Binding strDesBlocage}" Source="{Binding strImageToDisplay}" Visibility="{Binding strWorkingVisibility}">
                                        <Image.Style>
                                            <Style TargetType="Image">
                                                <Style.Triggers>
                                                    <Trigger Property ="IsMouseOver" Value="True">
                                                    </Trigger>
                                                </Style.Triggers>
                                            </Style>
                                            </Image.Style>
                                    </Image>
                                </UniformGrid>
                                <UniformGrid  Grid.Column="8" Grid.Row="0" Grid.RowSpan="4" >
                                    <Image Tag="{Binding strRueck}" ToolTip="{Binding strEmpAssigned}" Visibility="{Binding strAttributionVisibility}" MouseLeftButtonUp="ClickAttribution">
                                        <Image.Style>
                                            <Style TargetType="{x:Type Image}">
                                                <Setter Property="Source" Value="Images/Attribution.png"/>
                                                <Style.Triggers>
                                                    <Trigger Property="IsMouseOver" Value="True">
                                                        <Setter Property="Source" Value="Images/AttributionHover.png"/>
                                                    </Trigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Image.Style>
                                    </Image>
                                </UniformGrid>
                                <UniformGrid  Grid.Column="9" Grid.Row="0" Grid.RowSpan="4" >
                                    <Image Tag="{Binding strRueck}" ToolTip="{Binding strPostePrevCount}" Visibility="{Binding strRegroupementVisibility}" MouseLeftButtonUp="ClickRegroupement">
                                        <Image.Style>
                                            <Style TargetType="{x:Type Image}">
                                                <Setter Property="Source" Value="Images/Regroupement.png"/>
                                                <Style.Triggers>
                                                    <Trigger Property="IsMouseOver" Value="True">
                                                        <Setter Property="Source" Value="Images/Regroupement.png"/>
                                                    </Trigger>
                                                </Style.Triggers>
                                            </Style>
                                        </Image.Style>
                                    </Image>
                                </UniformGrid>
                                <UniformGrid Tag="{Binding strRueck}" Grid.Column="11" Grid.Row="0" Grid.RowSpan="3" HorizontalAlignment="Left" MouseLeftButtonUp="OpenPlan">
                                    <Image Source="Images/Plan.png" Visibility="Visible" />
                                    <UniformGrid.Style>
                                        <Style TargetType="{x:Type UniformGrid}">
                                            <Style.Triggers>
                                                <Trigger Property="IsMouseOver" Value="true">
                                                    <Setter Property="Background" Value="Gray"/>
                                                </Trigger>
                                                <Trigger Property="IsMouseOver" Value="false">
                                                    <Setter Property="Background" Value="Transparent"/>
                                                </Trigger>
                                            </Style.Triggers>
                                        </Style>
                                    </UniformGrid.Style>
                                </UniformGrid>
                                   <UniformGrid Tag="{Binding strRueck}" Grid.Column="11" Grid.Row="3" Grid.RowSpan="3" HorizontalAlignment="Left" MouseLeftButtonUp="OpenIT">
                                    <Image Source="Images/IT.png" Visibility="Visible" />
                                    <UniformGrid.Style>
                                        <Style TargetType="{x:Type UniformGrid}">
                                            <Style.Triggers>
                                                <Trigger Property="IsMouseOver" Value="true">
                                                    <Setter Property="Background" Value="Gray"/>
                                                </Trigger>
                                                <Trigger Property="IsMouseOver" Value="false">
                                                    <Setter Property="Background" Value="Transparent"/>
                                                </Trigger>
                                            </Style.Triggers>
                                        </Style>
                                    </UniformGrid.Style>
                                </UniformGrid>
                            </Grid>                            
                    </Border>
                </DataTemplate>
            </ItemsControl.ItemTemplate>
            <ItemsControl.ItemsPanel>
                <ItemsPanelTemplate>
                    <UniformGrid Columns="2"/>
                </ItemsPanelTemplate>
            </ItemsControl.ItemsPanel>
        </ItemsControl>
    </ScrollViewer>
        <Label HorizontalAlignment="Right" FontSize="14" Foreground="White" Grid.Row="4" Grid.Column="2" Content="{Binding strTotaux}"></Label>
    </Grid>
</Window>


My C# code :

C#
public partial class MainWindow : Window, INotifyPropertyChanged
    {
        #region Évenement qui permet de déclencher l'événement INotifyPropertyChanged et mettre à jour le binding
        public void Set<TValue>(ref TValue field, TValue newValue, [CallerMemberName] string propertyName = "")
        {
            if (EqualityComparer<TValue>.Default.Equals(field, default(TValue)) || !field.Equals(newValue))
            {
                field = newValue;
 
                if (PropertyChanged != null)
                    PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
            }
        }
 
        public event PropertyChangedEventHandler PropertyChanged;
        #endregion
 
        public static RangeObservableCollection<CL_Operation> _lstOperations = new RangeObservableCollection<CL_Operation>();
        public static RangeObservableCollection<CL_Operation> LstOperations
        {
            get { return _lstOperations; }
            set { _lstOperations = value; }
        }
 
        private string _strTotaux;
        public string strTotaux
        {
            get { return _strTotaux; }
            set { Set(ref _strTotaux, value); }
        }
 
        private string _strShowMenu;
        public string strShowMenu
        {
            get { return _strShowMenu; }
            set { Set(ref _strShowMenu, value); }
        }
 
        private string _strSelection;
        public string strSelection
        {
            get { return _strSelection; }
            set { Set(ref _strSelection, value); }
        }
 
        private string _strFiltres;
        public string strFiltres
        {
            get { return _strFiltres; }
            set { Set(ref _strFiltres, value); }
        }
 
public MainWindow()
        {
            InitializeComponent();
 
            DataContext = this;
        }
 
  public void GetList()
        {
            strShowMenu = "Hidden";
 
            RangeObservableCollection<CL_Operation> _lstOperationsTemp = new RangeObservableCollection<CL_Operation>();
 
            strSelection = "";
 
            foreach (var item in Var.lstSelectedLignesChoisi)
            {
                strSelection += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedIlotsChoisi)
            {
                strSelection += " " + item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedPostesTravailChoisi)
            {
                strSelection += " " + item.ToString() + " ";
            }
 
            strFiltres = "";
 
            foreach (var item in Var.lstSelectedOperations)
            {
                strFiltres += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedTypesDiamant)
            {
                strFiltres += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedClient)
            {
                strFiltres += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedMatricule)
            {
                strFiltres += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedTypeOrdre)
            {
                strFiltres += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedPriorites)
            {
                strFiltres += item.ToString() + " ";
            }
 
            if (!string.IsNullOrEmpty(Var.strFiltreNoOF))
                strFiltres += Var.strFiltreNoOF;
 
            if (!string.IsNullOrEmpty(Var.strFiltreArticle))
                strFiltres += Var.strFiltreArticle;
 
            if (!string.IsNullOrEmpty(Var.strFiltreComposant))
                strFiltres += Var.strFiltreComposant;
 
            if (!string.IsNullOrEmpty(Var.strFiltreAgentOrdo))
                strFiltres += Var.strFiltreAgentOrdo;
 
            if (!string.IsNullOrEmpty(Var.strFiltreGestMRP))
                strFiltres += Var.strFiltreGestMRP;
 
            if (!string.IsNullOrEmpty(Var.strFiltreSquelette) && Var.strFiltreSquelette != "TOUS")
                strFiltres += Var.strFiltreSquelette + " SQUELETTE";
 
            strWhere = "";
            strWhere = Where(Var.lstSelectedLignesChoisi, Var.lstSelectedIlotsChoisi, Var.lstSelectedPostesTravailChoisi, Var.lstSelectedOperations, Var.lstSelectedTypesDiamant, Var.lstSelectedClient, Var.lstSelectedMatricule, Var.lstSelectedTypeOrdre, Var.strFiltreArticle, Var.strFiltreNoOF, Var.strFiltreComposant, Var.strFiltreAgentOrdo, Var.strFiltreGestMRP, Var.lstSelectedPriorites, Var.strFiltreSquelette);
            CreateOrderBy();
 
            dvOps = dtOps.DefaultView;
 
            Application.Current.Dispatcher.Invoke(new Action(() => _lstOperationsTemp.Clear()));
            dtOps.Clear();
 
            string strQueryDatas;
 
            SqlConnection con = new SqlConnection(connectionString);
 
            strQueryDatas = "SELECT * FROM [DB].[dbo].[View_] " + strWhere + " " + strOrderBy;
 
            SqlDataAdapter adOps = new SqlDataAdapter(strQueryDatas, con);
 
            adOps.Dispose();
 
            try
            {
                con.Open();
                SqlCommand sqlCmd = new SqlCommand(strQueryDatas, con);
                sqlCmd.CommandTimeout = 500;
                adOps.SelectCommand = sqlCmd;
                adOps.Fill(dtOps);
                adOps.Dispose();
                sqlCmd.Dispose();
                con.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
 
            DateTime dtNow = DateTime.Now;
 
            double dblTotalQte = 0;
            double dblTotalOp = 0;
            double dblTotalTemps = 0;
            double dblTotalJoursRetard = 0;
 
            for (int i = 0; i < dvOps.Count; i++)
            {
                clOp = new CL_Operation();
 
                clOp.strWidth = Convert.ToString(Convert.ToInt32(System.Windows.SystemParameters.PrimaryScreenWidth) / 2);
 
                if (dvOps[i]["OP_IsWorking"].ToString().Trim() != "")
                    clOp.bIsWorking = Convert.ToBoolean(dvOps[i]["OP_IsWorking"].ToString().Trim());
                else
                    clOp.bIsWorking = false;
 
                clOp.bAnoOp = Convert.ToBoolean(dvOps[i]["AnoOP"].ToString().Trim());
 
                if (clOp.bIsWorking && clOp.bAnoOp)
                {
                    clOp.strImageToDisplay = "Images/TravailAnomalie.png";
                    clOp.strWorkingVisibility = "Visible";
                }
                else if (clOp.bAnoOp)
                {
                    clOp.strImageToDisplay = "Images/Anomalie.png";
                    clOp.strWorkingVisibility = "Visible";
                }
                else if (clOp.bIsWorking)
                {
                    clOp.strImageToDisplay = "Images/Travail.png";
                    clOp.strWorkingVisibility = "Visible";
                }
                else
                {
                    clOp.strImageToDisplay = "Images/Travail.png";
                    clOp.strWorkingVisibility = "Hidden";
                }
 
                if (dvOps[i]["OP_IsAssigned"].ToString().Trim() != "")
                    clOp.bIsAssigned = Convert.ToBoolean(dvOps[i]["OP_IsAssigned"].ToString().Trim());
                else
                    clOp.bIsAssigned = false;
 
                if (clOp.bIsAssigned)
                    clOp.strAttributionVisibility = "Visible";
                else
                    clOp.strAttributionVisibility = "Hidden";
 
                clOp.strDesBlocage = dvOps[i]["DesBlocage"].ToString().Trim();
 
                if(!string.IsNullOrEmpty(dvOps[i]["MATRICULE"].ToString().Trim()))
                    clOp.strMatriculeAssigned = Convert.ToInt32(dvOps[i]["MATRICULE"]).ToString().Trim();
 
                clOp.strNameAssigned = dvOps[i]["NAME"].ToString().Trim();
                clOp.strFirstNameAssigned = dvOps[i]["FIRSTNAME"].ToString().Trim();
                clOp.strEmpAssigned = dvOps[i]["NAME"].ToString().Trim() + " " + dvOps[i]["FIRSTNAME"].ToString().Trim();
                clOp.strNoOf = dvOps[i]["NumOF"].ToString().Trim();
                clOp.strNoOfOp = dvOps[i]["NumOF"].ToString().Trim() + " - " + dvOps[i]["NumOP"].ToString().Trim();
                clOp.strAuart = dvOps[i]["AUART"].ToString().Trim();
                clOp.strMaufnr = dvOps[i]["MAUFNR"].ToString().Trim();
                clOp.strCodeLigne = dvOps[i]["CodeLigne"].ToString().Trim();
                clOp.strRueck = dvOps[i]["RUECK"].ToString().Trim();
                clOp.strDescriptionOp = dvOps[i]["DesOpe"].ToString().Trim();
                clOp.strNoArticle = dvOps[i]["NumArt"].ToString().Trim();
                clOp.strDateFormatee = dvOps[i]["DateFormatee"].ToString().Trim();
                clOp.strPcesPoste = Convert.ToString(Convert.ToDouble(String.Format("{0:0}", dvOps[i]["QtePoste"].ToString().Trim()))) + " pces";
                clOp.strTpsPoste = Convert.ToString(Convert.ToDouble(String.Format("{0:0.00}", dvOps[i]["TpsChargePoste"].ToString()))) + " Hrs";
                clOp.strClient = dvOps[i]["NomClientCourt"].ToString().Trim();
                clOp.strTypeOp = dvOps[i]["MAKTX"].ToString().Trim();
                clOp.strPriorite = dvOps[i]["PriorOF"].ToString().Trim();
                clOp.strSsSect = dvOps[i]["SsSect"].ToString().Trim();
                clOp.strDateDerBadge = Convert.ToDateTime(dvOps[i]["DatDerBadg"]);
                clOp.strWorkStart = dvOps[i]["DATETIMEDEBUT"].ToString().Trim();
                clOp.strNumOp = dvOps[i]["NumOpSt"].ToString().Trim();
                clOp.strIDRegroupement = dvOps[i]["USR02"].ToString().Trim();
                clOp.strFlagPostePrev = dvOps[i]["FlagPostePrev"].ToString().Trim();
                clOp.strNumArtPere = dvOps[i]["NumArtPere"].ToString().Trim();
                clOp.strMAKTXPere = dvOps[i]["MAKTXPere"].ToString().Trim();
 
                //int iCountRegr = 0;
 
                if (!string.IsNullOrEmpty(clOp.strIDRegroupement))
                {
                    //string strQueryDatas2;
 
                    //SqlConnection con2 = new SqlConnection(connectionString);
                    SqlConnection con3 = new SqlConnection(connectionString);
                    SqlConnection con4 = new SqlConnection(connectionString);
 
                    //strQueryDatas2 = "SELECT COUNT (*) FROM [db].[dbo].[view] WHERE USR02 = '" + clOp.strIDRegroupement + "'";
 
                    //try
                    //{
                    //    con2.Open();
                    //    SqlCommand sqlCmd = new SqlCommand(strQueryDatas2, con2);
                    //    iCountRegr = (Int32)sqlCmd.ExecuteScalar();
                    //    //sqlCmd.CommandTimeout = 500;
                    //    con2.Close();
                    //}
                    //catch (Exception ex)
                    //{
                    //    MessageBox.Show(ex.Message);
                    //}
 
                    string strQueryDatas3;
 
                    strQueryDatas3 = "SELECT COUNT (*) FROM [db].[dbo].[Table] WHERE FlagPostePrev = 'POSTE' AND USR02 = '" + clOp.strIDRegroupement + "'";
 
                    try
                    {
                        con3.Open();
                        SqlCommand sqlCmd = new SqlCommand(strQueryDatas3, con3);
                        clOp.iCountRegrPoste = (Int32)sqlCmd.ExecuteScalar();
                        //sqlCmd.CommandTimeout = 500;
                        con3.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
 
                    string strQueryDatas4;
 
                    strQueryDatas4 = "SELECT COUNT (*) FROM [db].[dbo].[Table] WHERE FlagPostePrev = 'PREV' AND USR02 = '" + clOp.strIDRegroupement + "'";
 
                    try
                    {
                        con4.Open();
                        SqlCommand sqlCmd = new SqlCommand(strQueryDatas4, con4);
                        clOp.iCountRegrPrev = (Int32)sqlCmd.ExecuteScalar();
                        //sqlCmd.CommandTimeout = 500;
                        con4.Close();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
 
                    clOp.strPostePrevCount = "Poste : " + clOp.iCountRegrPoste.ToString() + " / Prév : " + clOp.iCountRegrPrev.ToString();
                }
 
                if (string.IsNullOrEmpty(clOp.strIDRegroupement))
                    clOp.strRegroupementVisibility = "Hidden";
                else
                    clOp.strRegroupementVisibility = "Visible";
 
                Application.Current.Dispatcher.Invoke(new Action(() => _lstOperationsTemp.Add(clOp)));
 
                DateTime dtRetard = Convert.ToDateTime(clOp.strDateFormatee);
                DateTime dtTempsPoste = Convert.ToDateTime(clOp.strDateDerBadge);
                TimeSpan tRetard = dtNow.Date - dtRetard.Date;
 
                if (dtTempsPoste.ToString() == "01.01.1900 00:00:00")
                    dtTempsPoste = dtNow;
 
                TimeSpan tTempsPoste = dtNow - dtTempsPoste;
 
                dblTotalQte += Convert.ToDouble(dvOps[i]["QtePoste"].ToString().Trim());
                dblTotalTemps += Convert.ToDouble(dvOps[i]["TpsChargePoste"].ToString().Trim());
                dblTotalOp++;
 
                clOp.strRetardAvanceText = Convert.ToString(Math.Abs(Convert.ToDouble(tRetard.TotalDays))) + " jrs";
 
 
 
                clOp.scbBackColor.Freeze();
                clOp.scbColorRetardAvance.Freeze();
            }
 
            strTotaux = "Total retard : " + dblTotalJoursRetard.ToString() + " Jours     Nb OPs : " + dblTotalOp.ToString() + "     Qte totale : " + dblTotalQte.ToString() + " Pces     Temps total : " + dblTotalTemps + " Hrs";
 
            Application.Current.Dispatcher.Invoke(new Action(() => LstOperations.Clear()));
            Application.Current.Dispatcher.Invoke(new Action(() => LstOperations.AddRange(_lstOperationsTemp)));
 
            Var.lstSelectedOperations.Clear();
            Var.lstSelectedTypesDiamant.Clear();
            Var.lstSelectedClient.Clear();
            Var.lstSelectedMatricule.Clear();
            Var.lstSelectedTypeOrdre.Clear();
            Var.strFiltreNoOF = "";
            Var.strFiltreArticle = "";
            Var.strFiltreComposant = "";
            Var.strFiltreAgentOrdo = "";
            Var.strFiltreGestMRP = "";
            Var.strFiltreSquelette = "";
 
            strShowMenu = "Visible";
        }
 
}


What I have tried:

I realized with this code :

C#
strSelection = "";

           foreach (var item in Var.lstSelectedLignesChoisi)
           {
               strSelection += item.ToString() + " ";
           }

           foreach (var item in Var.lstSelectedIlotsChoisi)
           {
               strSelection += " " + item.ToString() + " ";
           }

           foreach (var item in Var.lstSelectedPostesTravailChoisi)
           {
               strSelection += " " + item.ToString() + " ";
           }

           strFiltres = "";

           foreach (var item in Var.lstSelectedOperations)
           {
               strFiltres += item.ToString() + " ";
           }

           foreach (var item in Var.lstSelectedTypesDiamant)
           {
               strFiltres += item.ToString() + " ";
           }

           foreach (var item in Var.lstSelectedClient)
           {
               strFiltres += item.ToString() + " ";
           }

           foreach (var item in Var.lstSelectedMatricule)
           {
               strFiltres += item.ToString() + " ";
           }

           foreach (var item in Var.lstSelectedTypeOrdre)
           {
               strFiltres += item.ToString() + " ";
           }

           foreach (var item in Var.lstSelectedPriorites)
           {
               strFiltres += item.ToString() + " ";
           }

           if (!string.IsNullOrEmpty(Var.strFiltreNoOF))
               strFiltres += Var.strFiltreNoOF;

           if (!string.IsNullOrEmpty(Var.strFiltreArticle))
               strFiltres += Var.strFiltreArticle;

           if (!string.IsNullOrEmpty(Var.strFiltreComposant))
               strFiltres += Var.strFiltreComposant;

           if (!string.IsNullOrEmpty(Var.strFiltreAgentOrdo))
               strFiltres += Var.strFiltreAgentOrdo;

           if (!string.IsNullOrEmpty(Var.strFiltreGestMRP))
               strFiltres += Var.strFiltreGestMRP;

           if (!string.IsNullOrEmpty(Var.strFiltreSquelette) && Var.strFiltreSquelette != "TOUS")
               strFiltres += Var.strFiltreSquelette + " SQUELETTE";


I modify my binding to all foreach, it's maybe the the cause of my problem.

I try :

C#
string strFiltresTemp = "";
            string strSelectionTemp = "";
 
 
 
            foreach (var item in Var.lstSelectedLignesChoisi)
            {
                strSelectionTemp += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedIlotsChoisi)
            {
                strSelectionTemp += " " + item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedPostesTravailChoisi)
            {
                strSelectionTemp += " " + item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedOperations)
            {
                strFiltresTemp += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedTypesDiamant)
            {
                strFiltresTemp += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedClient)
            {
                strFiltresTemp += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedMatricule)
            {
                strFiltresTemp += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedTypeOrdre)
            {
                strFiltresTemp += item.ToString() + " ";
            }
 
            foreach (var item in Var.lstSelectedPriorites)
            {
                strFiltresTemp += item.ToString() + " ";
            }
 
            if (!string.IsNullOrEmpty(Var.strFiltreNoOF))
                strFiltresTemp += Var.strFiltreNoOF;
 
            if (!string.IsNullOrEmpty(Var.strFiltreArticle))
                strFiltresTemp += Var.strFiltreArticle;
 
            if (!string.IsNullOrEmpty(Var.strFiltreComposant))
                strFiltresTemp += Var.strFiltreComposant;
 
            if (!string.IsNullOrEmpty(Var.strFiltreAgentOrdo))
                strFiltresTemp += Var.strFiltreAgentOrdo;
 
            if (!string.IsNullOrEmpty(Var.strFiltreGestMRP))
                strFiltresTemp += Var.strFiltreGestMRP;
 
            if (!string.IsNullOrEmpty(Var.strFiltreSquelette) && Var.strFiltreSquelette != "TOUS")
                strFiltresTemp += Var.strFiltreSquelette + " SQUELETTE";


And in the end of my code only i update my binding :

C#
Application.Current.Dispatcher.Invoke(new Action(() => LstOperations.Clear()));
            Application.Current.Dispatcher.Invoke(new Action(() => LstOperations.AddRange(_lstOperationsTemp)));
 
            strSelection = strSelectionTemp;
            strFiltres = strFiltresTemp;
            strTotaux = "Total retard : " + dblTotalJoursRetard.ToString() + " Jours     Nb OPs : " + dblTotalOp.ToString() + "     Qte totale : " + dblTotalQte.ToString() + " Pces     Temps total : " + dblTotalTemps + " Hrs";


Sadly, the problem is the same. On my computer, any problems. On another computer, i see the list disppears and appears. Even if this flash it's very fastly, i need to hide this symptom.

How do ? I don't see another location in my code where i modify my binding.

As you can see at the top of my GetList function, I put the ShowMenu button to Hidden, then I put it back to Visible at the end.

I noticed that the list does not disappear when I see the button disappear, but the list disappears and then reappears very quickly only when the button reappears also.

If I do not make the clear of my list Application.Current.Dispatcher.Invoke (new Action (() => LstOperations.Clear ())); this behavior no longer intervenes on any PC, so it works as I wish. But, of course, my list accumulates instead of crashing.

How to do ? Should I calculate a delta to be totally transparent ??

The .clear and .AddRange of the Temp list are apparently not fast enough, unfortunately.

On my PC: when I request data, the list is visible when it executes my getlist function, I can even interact with the application, then I can not do anything on the application during the time it refreshes the binding when it has finished the data recovery.
That is what I want.

On the other PC: it disappears then reappear the list.

On my PC I can take 3000 lines, no disappearance / reappearance of list

on the other PC: I take 1 line and this behavior is.

Thank you in advance, thank you very much.
Posted
Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900