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: 
One more solution:

```
$arr = array('unset_me','leave_me','whatever',);  
print_r($arr);

// remove the elements that you want  
$arr = array_diff($arr, array("unset_me"));
print_r($arr);  

```
I recently encountered this problem and found this solution helped:

`unset($a[array_flip($a)['unset_me']]);`

Just to explain what is going on here:

`array_flip($a)` switches the items for the key. So it would become:

```
$a = [
    'unset_me' => 0,
    'leave_me' => 1,
    'whatever' => 2,
];

```

`array_flip($a)['unset_me']` therefore resolves to being 0. So that expression is put into the original `$a` which can then be unset.

2 caveats here:

* This would only work for your basic array, if you had an array of objects or arrays, then you would need to choose one of the other solutions
* The key that you remove will be missing from the array, so in this case, there will not be an item at `0` and the array would start from `1`. If it is important to you, you can do `array_values($a)` to reset the keys.