누구든지이 코드가 동시성을 유발할 수 있는지 여부를 알려주십시오.Concurrecy In Static Classes
이것은 양식에서 사용되며 일부 데이터베이스 트랜잭션에 사용되는 정적 클래스입니다.
이것은 asp.net 페이지에서 정적 함수를 호출하고 매개 변수를 ref 유형으로 전달하는 것과 관련됩니다.
참조 유형을 사용하고 있습니다.
웹 기반이므로 일부 동시성을 만듭니다. 여기 ///
내 샘플 클래스에서 코드입니다.
public static class DataClass
{
static SqlConnection con = new SqlConnection(
ConfigurationManager.ConnectionStrings["sqlserverconnectionstring"]
.ConnectionString);
public static string GetCon()
{
return ConfigurationManager.ConnectionStrings["sqlserverconnectionstring"].ConnectionString;
}
public static void Conn(ref SqlConnection con)
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
}
public static DataSet GetDataSet(string qry)
{
SqlDataAdapter adp = new SqlDataAdapter(qry, con);
DataSet ds = new DataSet();
adp.Fill(ds);
return ds;
}
public static bool ExecuteCommand(ref SqlCommand cmd)
{
bool i =true;
cmd.Connection = con;
Conn(ref con);
SqlTransaction trans =con.BeginTransaction();
cmd.Transaction = trans;
try
{
cmd.ExecuteNonQuery();
trans.Commit();
}
catch
{
trans.Rollback();
i = false;
}
finally
{
cmd.Dispose();
con.Close();
}
return i;
}
}
동시성이 올바른 단어가 아닌 것 같습니다. 당신이 묻고있는 것을 다시 말해 줄 수 있습니까? –
함수 호출에 전달 된 값이 동시 호출에서 겹칠 수있는 경우 두려워하더라도 동시 스레드에서 생각합니다. – Rohit