title: How to not freeze the UI, and wait for response?
body: <p>I've been trying since the morning but I didnt achieve what I wanted.</p>
  
  <p>I tried DispatchQueue.main.async and completion block but my "Submit" button in the UI still freezes waiting for the data to be returned from the server. This is my code:</p>
  
  <pre><code>func createData(request:Crudpb_CreateRequest, with completion: @escaping (String) -&gt; Void) throws {
      DispatchQueue.main.async {
          self.response = try! self.client.create(request) // &lt;---- How to handle error for this server call when the server is not available or is down?
          completion(self.response.result)
      }
  }
  </code></pre>
  
  <p>I just noticed Im calling the 1st method from the following which is a Synchronous Unary which might be the reason behind the problem. But again I dont know how to call the second function in the fallowing:</p>
  
  <pre><code> /// Synchronous. Unary.
    internal func create(_ request: Crudpb_CreateRequest, metadata customMetadata: Metadata) throws -&gt; Crudpb_CreateResponse {
      return try Crudpb_CrudServiceCreateCallBase(channel)
        .run(request: request, metadata: customMetadata)
    }
    /// Asynchronous. Unary.
    @discardableResult
    internal func create(_ request: Crudpb_CreateRequest, metadata customMetadata: Metadata, completion: @escaping (Crudpb_CreateResponse?, CallResult) -&gt; Void) throws -&gt; Crudpb_CrudServiceCreateCall {
      return try Crudpb_CrudServiceCreateCallBase(channel)
        .start(request: request, metadata: customMetadata, completion: completion)
    }
  </code></pre>
  
  <p>Server Side Code:</p>
  
  <pre><code>func (*server) Create(ctx context.Context, req *crudpb.CreateRequest) (*crudpb.CreateResponse, error) {
  
      var result string
      firstName := req.GetAccount().GetFirstName()
      lastName := req.GetAccount().GetLastName()
      //  id := gocql.TimeUUID()
  
      fmt.Println("Triggered CREATE function on Go Server " + firstName + " " + lastName + "! Yayy!")
  
      result = fmt.Sprintf("id for %s %s : %s", firstName, lastName, strconv.Itoa(rand.Intn(100)))
      return &amp;crudpb.CreateResponse{
          Result: result,
      }, nil
  </code></pre>
  
  <p>I need this app / submit button not to freeze while it fetches result from server.</p>
  
  <p>Please help.</p>