Question: The following simplified code (C#) is the server side of an SSE. When I use `Thread.Sleep()` instead of `Response.Write("retry:10000\n\n")` other ajax request keep hanging. How do I create a proper SSE event-stream?

```
Response.ContentType = "text/event-stream";
DateTime echo;

while (true)
{
    var db = Database.Open("SSE");
    echo = db.QueryValue("select last_change from table");
    db.Close();
    Response.Write(string.Format("data:{1}\n\n", echo.GetHashCode()));

    ///// debug this works 
    Response.Write("retry:10000\n\n");
    Response.Flush();
    Response.Close();
    return;
    /////////// this doesn't work

    Response.Flush();
    if (Response.IsClientConnected == false)
    {
        break;
    }
    System.Threading.Thread.Sleep(10000);

}

```

P.S. I am also planning on using a `SqlDependency`, but haven't figured this out yet.

EDIT:
I'm thinking the problems lies with the sessionstate.

Answer: 
You can try this with `array_search` - 

```
unset($a[array_search('unset_me', $a)]);

```

If needed then add the checks like -

```
if(array_search('unset_me', $a) !== false) {
    unset($a[array_search('unset_me', $a)]);
}

```

[Demo](https://eval.in/488555)
```
$arr = array('unset_me','leave_me','whatever',);  
print_r($arr);
echo '<br/>';

$key = array_search('unset_me', $arr);
if($key !== false)
unset($arr[$key]);

print_r($arr);

```