Calling a function blocks the entire application and the user until the function terminates. If the function doesn't terminate, then there is no opportunity for the user to suspend the runaway function. In the context of client-server applications, clients must wait for the server until the current client finishes.
Use multithreading to divide the application into a foreground master thread that manages a number of background slave threads that do the actual computational work:

In a desktop application the master listens for user inputs, then launches slaves to execute user commands.
In a client-server application the master listens for client requests. When a request is received the master creates a slave to serve the client.
A master trying to solve the Travelling Salesman Problem creates a slave for each path through the graph. The slave computes the length of its path (in O(n) time) and reports it back to the master, which keeps track of the shortest path.