Пример #1
0
        public void CancelSingleQuery()
        {
            if (Version < new Version(5, 0))
            {
                return;
            }

            // first we need a routine that will run for a bit
            execSQL(@"CREATE PROCEDURE spTest(duration INT) 
                BEGIN 
                    SELECT SLEEP(duration);
                END");

            MySqlCommand cmd = new MySqlCommand("spTest", conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("duration", 10);

            // now we start execution of the command
            CommandInvokerDelegate d = new CommandInvokerDelegate(CommandRunner);

            d.BeginInvoke(cmd, null, null);

            // sleep 1 seconds
            Thread.Sleep(1000);

            // now cancel the command
            cmd.Cancel();
        }
    public void CancelSingleQuery()
    {
      if (st.Version < new Version(5, 0)) return;

      // first we need a routine that will run for a bit
      st.execSQL(@"CREATE PROCEDURE spTest(duration INT) 
        BEGIN 
          SELECT SLEEP(duration);
        END");

      MySqlCommand cmd = new MySqlCommand("spTest", st.conn);
      cmd.CommandType = CommandType.StoredProcedure;
      cmd.Parameters.AddWithValue("duration", 10);

      // now we start execution of the command
      CommandInvokerDelegate d = new CommandInvokerDelegate(CommandRunner);
      d.BeginInvoke(cmd, null, null);

      // sleep 1 seconds
      Thread.Sleep(1000);

      // now cancel the command
      cmd.Cancel();

      resetEvent.WaitOne();
    }
Пример #3
0
        public void CancelSingleQuery()
        {
            // first we need a routine that will run for a bit
            executeSQL(@"CREATE PROCEDURE CancelSingleQuery(duration INT) 
        BEGIN 
          SELECT SLEEP(duration);
        END");

            MySqlCommand cmd = new MySqlCommand("CancelSingleQuery", Connection);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("duration", 10);

            // now we start execution of the command
            CommandInvokerDelegate d = new CommandInvokerDelegate(CommandRunner);

            d.BeginInvoke(cmd, null, null);

            // sleep 1 seconds
            Thread.Sleep(1000);

            // now cancel the command
            cmd.Cancel();

            Assert.True(resetEvent.WaitOne(30 * 1000), "timeout");
        }
Пример #4
0
 public void Configure(Metadata metadata, Metadata.Command command)
 {
     this.serializer             = new PcaJsonSerializer(metadata);
     this.metadata               = metadata;
     this.command                = command;
     this.commandInvokerDelegate = BuildCommandInvoker();
     this.supportsCancellation   =
         // IObservable<T>
         command.MethodInfo.ReturnType.IsGenericType && typeof(IObservable <>).IsAssignableFrom(command.MethodInfo.ReturnType.GetGenericTypeDefinition()) ||
         // or one of the parameters is a CancellationToken
         command.MethodInfo.GetParameters().Any(par => par.ParameterType == typeof(CancellationToken));
 }