public virtual ILinearSolution Solve(ISolverParameters parameters)
        {
            lock (classLock)
            {
                if (env != null) /* If shutdown has already been called, env may be null.  */
                {
                    mosek.Task task = null;
                    task = new mosek.Task(env, 0, 0);
                    task.set_Stream(mosek.streamtype.log, null);
                    task.set_Stream(mosek.streamtype.msg, null);
                    task.set_Stream(mosek.streamtype.err, null);

                    MosekSolverParams mosekParams = parameters as MosekSolverParams;

                    interrupted    = false;
                    primalObjIsdef = false;

                    foreach (System.Diagnostics.TraceListener listener in mosekParams.GetListeners())
                    {
                        msgStream.AddListener(listener);
                    }

                    if (msgStream.listeners.Count > 0)
                    {
                        task.set_Stream(mosek.streamtype.log, msgStream);
                    }

                    mosekParams.LoadMosekParams(task);
                    progressCB = new MosekProgress(parameters.QueryAbort);

                    task.ProgressCB = progressCB;

                    if (disposed)
                    {
                        progressCB.Abort();
                    }

                    LoadData(task);

                    if (mosekParams.TaskDumpFileName != null)
                    {
                        task.writedata(mosekParams.TaskDumpFileName);
                    }

                    try
                    {
                        task.optimize();
                    }
                    catch (mosek.Warning w)
                    {
                        if (w.Code == mosek.rescode.trm_user_callback)
                        {
                            interrupted = true;
                            // feasible solutions ?
                            if (task.getintinf(mosek.iinfitem.mio_num_int_solutions) > 0)
                            {
                                foundIntSolution = true;
                            }
                        }
                    }
                    catch (mosek.Error e)
                    {
                        throw new MosekMsfException(e.ToString());
                    }

                    if (task.getintinf(mosek.iinfitem.mio_num_relax) > 0)
                    {
                        mipBestBound = task.getdouinf(dinfitem.mio_obj_bound);
                    }

                    task.solutionsummary(mosek.streamtype.log);

                    UpdateSolution(task);
                    progressCB = null;
                    if (task != null)
                    {
                        task.Dispose();
                        task = null;
                    }
                }
            }

            ILinearSolution sol = CreateLinearSolution();

            return(sol);
        }