dcsimg
Results 1 to 2 of 2

Thread: How To Show Image For 10 Second Period Then Will Be Null After That ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2018
    Posts
    64

    How To Show Image For 10 Second Period Then Will Be Null After That ?

    problem

    How to show image for 10 second period then will be null After that ?

    I have TimerCount on windows form get last image on table members every second

    and this is work success using windows form timer on visual studio 2017 .

    and I need when new image retrieved show this image for 10 second then make it null



    Code:
    picturebox1.image=null


    After that will be null in case of not new image retrieved

    and within 10 second if new image retrieved by TimerCount not wait for ten second

    show image per 10 second only if no image retrieved within ten second

    and if after 10 second no image retrieved set image to null ?

    Code:
    pseudo code
    
    
    if(new image retrieved )
    
    {
    
    show it per 10 second
    
    }
    
    if(after 10 second no image retrived)
    
    {
    
    picturebox1.image=null;
    
    }
    
    if(new image retrieved by timercount)
    
    {
    
    not wait until 10 second display for current image
    
    }
    can you help me or give me idea for that please ?

    What I have tried:



    Code:
    private void TimerCount_Tick(object sender, EventArgs e)
    
            {
    
                
    
                TimerCount.Start();
    
                GetMembersDataImage();
    
                    
    
            }
    
    
    public void GetMembersData()
    
           {
    
                string sqlGetLast = @"select isnull((select top 1 MemberCode from members order by MemberCode desc),1) ";
    
                 MemberCode = Utilities.ObjectConverter.ConvertToInteger(DataAccess.ExecuteScalar(sqlGetLast));
    
                string sqlImage = "select MemberImage FROM Members WHERE MemberCode =" + MemberCode + "";
    
                if (Utilities.ObjectConverter.ConvertToString(DataAccess.ExecuteScalar(sqlImage)) != "")
    
                {
    
                    byte[] MemberImage = (byte[])DataAccess.ExecuteScalar(sqlImage);
    
                    Gate1Pic.Image = ByteArrayToImagebyMemoryStream(MemberImage);
    
                }
    
    }

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    5,622

    Re: How To Show Image For 10 Second Period Then Will Be Null After That ?

    If I understand the situation, I do something along that line with what I call a Watchdog counter.

    You create an integer variable to act as a watchdog counter.
    In the timer, each tick (one second interval) you:

    decrement the counter.

    You check for a picture, and if you have one, you show it and set the counter to 10.

    You check the value of the counter and if it is 0, you null the picture.


    So, as long as you get a picture within the 10 second window, you show it and reset the counter to 10.
    If you don't have a picture in 10 seconds, the counter will reach 0 and you'll null the picture.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width