Execute a function until 5 minutes WPF : In a WPF form I'm calling doSomeFunction() method in a while loop. This will run until x = y. This is working fine.


                
                while (x != y)
                {
                   doSomeFunction();
                }

I need to add additional function, that need to check this condition until 5 minutes only. After the 5 minutes if x != y I need to return.

How can I do this in WPF?